+ 3
Why is the result here constantly 41 if it is meant to produce random numbers?
#include <iostream> #include <cstdlib> using namespace std; int main() { cout << rand(); // Outputs 16 return 0; }
4 Answers
+ 3
Add these:
#include <ctime>
Before use rand:
srand(time(0));
No idea why, random numbers are annoying in C++
+ 3
this code with some comment might help a little,
srry no comments were there but basically I m using input age as a seed value to produce a specific random no. for that age
https://code.sololearn.com/cYh9VfKXfbfC/?ref=app
+ 1
That gave random numbers, thanks. Is this using time to randomize?