Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6771151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:23:53+00:00 2026-05-26T15:23:53+00:00

Just like in Java , (Math . random * ) statement is there a

  • 0

Just like in Java , (Math . random * ) statement is there a way to input array numbers in C++ ?

For example I want to input numbers from 6 to 89 with RANDOM numbers in C++. Assign them into arrays.

I know how to sort the numbers but I would just like to know the method to do random numbers to make my life easier.

I am rusty in programming and I am open to any criticism but I would appreciate a straightforward response.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:23:53+00:00Added an answer on May 26, 2026 at 3:23 pm

    Use srand to seed the random number generator, then use rand to get a random number.

    For example, the following program populates an array with rando values in your requested range:

    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    
    int main (void) {
        int xyzzy[10];
    
        // Seed the generator.
    
        std::srand (time (0));
    
        // Populate the array.
    
        for (int i = 0; i < sizeof(xyzzy) / sizeof(*xyzzy); i++)
            xyzzy[i] = 6 + (std::rand() % 84);
    
        // Print the array.
    
        for (int i = 0; i < sizeof(xyzzy) / sizeof(*xyzzy); i++)
            std::cout << xyzzy[i] << "\n";
    
        return 0;
    }
    

    This outputs (in my case):

    59
    51
    84
    83
    58
    85
    83
    25
    50
    22
    

    Keep in mind that the properties of those random numbers may not be perfect due to the way they’re generated but, unless you’re a statistician or cryptographer, they should be fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just like in JavaScript : opener.document.getElementByName jQuery: ?? Is there any way to get
I need to format decimal numbers with patterns in J2ME just like java DecimalFormat
I just started with Java and downloaded Netbeans, i kind of like it, but
Just like stackoverflow, there is a many-to-many relationship between Question and Tag. After running
My Java application sometimes stays at system tray, just like MSN messenger does. I
I would like to know if there is any api available for Java which
I am looking for some efficient way for building a immutable class, just like
PHP is execute line by line or just like java that it's compiled form
Currently I run my program like this: java program arg1 arg2 arg3... There are
I would just like to have an Android XML UI file in Java. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.