- 2

what is rand()? pls explain me.

#include<iostream> #include<cstdlib> using namespace std; int main() { cout<<rand(); } how can be it's output 41? please explain it.

25th Sep 2017, 2:33 PM
Shivani Goyal
1 Answer
+ 1
Random Numbers Being able to generate random numbers is helpful in a number of situations, including when creating games, statistical modeling programs, and similar end products. In the C++ standard library, you can access a pseudo random number generator function that's called rand(). When used, we are required to include the header <cstdlib>. ------------------------- For real random number you can use it, because you use a seed The srand() Function The srand() function is used to generate truly random numbers. This function allows to specify a seed value as its parameter, which is used for the rand() function's algorithm.
18th Nov 2017, 7:35 AM
Daniel
Daniel - avatar