0
Why is it not giving random number?
it only giving 41 as a result
3 Answers
+ 14
You need to randomise the seed for RNG algorithm. The most commonly used way is by using system time.
#include <iostream>
#include <cstdlib>
#include <ctime>
int main()
{
srand(time(0));
std::cout << rand();
return 0;
}
+ 10
because you didn't use srand(time(0));