asked 144k views
5 votes
Which of the following statements generates a random number between 0 and 50?

1 Answer

4 votes

The statement that generates a random number between 0 and 50 is option C. srand(time(10));

num = rand() % 50;

What is the rand () and Srand () about?

When a person run the program, the same random number will be generated each time by the C++ rand() function. The srand(unsigned int seed) function is used to seed the rand() function. The pseudo-random number generation's starting point is set by the srand() function.

Note that a pseudo-random integer in the range of 0 to RAND MAX is returned by the C library function int rand(void). The default value of the constant RAND MAX is one that often varies depending on the implementation.

answered
User Babcool
by
8.0k points

No related questions found