Why is rand () returning same numbers ? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок

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