Why is rand () returning same numbers ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is rand () returning same numbers ?

when i try rand () function it returns 41 just like sololearn example in functions chapter. why are they same ? it should be randoming numbers?

4th Feb 2017, 10:51 AM
Safa Arica
Safa Arica - avatar
1 Answer
+ 3
you have to use srand function before using rand. example: srand((unsigned)time(0)); rand() % 50;
4th Feb 2017, 10:58 AM
Nedim Kanat
Nedim Kanat - avatar