answersLogoWhite

0

Use the random number generator classes.

#include<random>

#include<ctime>

std::default_random_engine generator ((unsigned)time(0)); // seed the generator

std::uniform_int_distribution<int> distribution (0, 100); // set the closed range

int r = distribution (generator); // pick a random number from 0 to 100 (inclusive)

Any device can be used to seed the generator. Here, we've simply used the current time. If you don't seed the generator, it will generate the same sequence of random values every time the program is run.

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

What is randomize function in c plus plus?

You can use rand(). Make sure that you use srand()to generate the seed for rand() (if you do not, you get so called pseudo random numbers).


What is rand function in c plus plus?

The rand() function returns an integer (int) value that represents a pseudo-random number between 0 and RAND_MAX, RAND_MAX being a constant declared in the run-time library. Each time rand() is invoked, a different value is returned.


How do you calculate the size of a class in memory in C plus plus?

Use sizeof( ).


What has the author Marguerite C Rand written?

Marguerite C. Rand has written: 'Ramo n Pe rez de Ayala'


How do you calculate percentage of marks obtained in 1 subject in c plus plus?

You can't, you have to come up with variables to calculate grades


Can anyone give you the c plus plus code to check where the line ax plus by plus c cuts the circle x2 plus y2 plus 2gx plus 2fy plus c equals 0 where a b c g f are entered by the user?

Your question is not clear. Please give the formula to calculate the value of x and the condition at which the line cuts the circle


C plus plus program calculate the power value of input base and exponent numbers?

cn = c0 *( 1 + i ) pow n


Can anyone give a code for c plus plus to do a random dice roll for a dropped item when a crate is destroyed?

int die = ((double)rand())*6/RAND_MAX+1; // result is 1, 2, 3, 4, 5, or 6


How do you calculate formula for a plus b plus c plus d equals 12 when a equals b plus c and c equals d?

There are four unknown variables and only three linear equations so there is not a unique solution. All you can do is to rearrange the four variables so that three of them can be expressed in terms of the fourth. For example: In terms of c, a = 6 - c/2 b = a - c = 6 - 3c/2 d = c


What has the author Neill C Ostrander written?

Neill C. Ostrander has written: 'The Rand Sync-Sat Calculator' -- subject(s): Rand Sync-Sat Calculator, Syncom (Communications satellite)


What is b plus b plus b plus c plus c plus c plus c?

b+b+b+c+c+c+c =3b+4c


What is 12.5 plus C 27.3?

To calculate 12.5 plus 27.3, simply add the two numbers together. The sum is 39.8. Therefore, 12.5 plus 27.3 equals 39.8.

Trending Questions
How do you clean and prepare the surfaces to be marked out ensuring where appropriate that grain flow is taken into account? What do you have to do to become an agricultural engineer? How do you make a simple and easy pulley? Will the speed of an aeroplane be same which is flying at different altitudes and have same mach number 2? Solutions for System Analysis and Design for the Global Enterprise. anyone knows where can i find solutions for System Analysis and Design for the Global Enterprise by Bentley and Whitten 7th edition? What do these two changes have in common sewing an apron mixing sand and water? Hello anyoneCan you please explain the terms light weight and heavy weight in java? How do you find the size of a class object? What is a blind bias? What does an inclined plane do? What does IP3 mean in RF? How do you create a flowchart that will accept a number and print the integers and the product of the integers of the number? What is most important to consider when choosing an appropriate tone for your technical writhing? Is there an antonym for equipment? What is the use of numerical analysis and why you have to study? How can you fix plumbing when the upstairs hot water in the shower turns off when the taps or shower downstairs are running? Why my generac generator cord want lock into my generator? Is “C language” case sensitive programminIs “C language” case sensitive programming language If yes why and if no whyg language If yes why and if no why? How do you prepare the materials in readiness for the marking out activities in order to enhance clarity accuracy and safety (such as visually checking for defects cleaning the materials removing burr? How many types of 7 passenger vehicles are available?