So in this instance 98 is our seed value, what does that exactly mean? Does it mean we start 98? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

So in this instance 98 is our seed value, what does that exactly mean? Does it mean we start 98?

int main () { srand(98); for (int x = 1; x <= 10; x++) { cout << 1 + (rand() % 6) << endl; } } in this scenario though are numbers won't go higher than 6

11th Apr 2018, 3:48 PM
Sir
2 Answers
0
so the function (srand) is creating a random-like number basen on your seed (try to look up the internet if you want to know how), so if you alwayspass the same value on it, it is very likely to produce the same output. the trick is, to have so real pseudo random values, you pass Time as an argument: srand(time()) take a look at the internet what function returns a time that have passed since 1970 (or something like that). By passing it as a value to a function, seed changes every time you generate a random number, so the randomness of a value is just more random!
11th Apr 2018, 5:43 PM
Paul
11th Apr 2018, 5:49 PM
Aaron Eberhardt
Aaron Eberhardt - avatar