Sunday, 11 February 2018

How to generate random numbers in C++

In C++ we have a function called randomize() using which we can generate random numbers.

randomize() – this function is utilized to create random numbers each time, when you execute program.

rand() – this function is utilized to return random number from 0 to RAND_MAX-1. Here RAND_MAX is the greatest scope of the number. On the off chance that you need to create random numbers from 0 to 99 then RAND_MAX will be 100.

The two functions are defined and declared in stdlib.h header document, so you need to incorporate this header file in program's header consideration area.

No comments:

Post a Comment