- 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.
1 ответ
+ 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.