Always 41 out | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Always 41 out

24th Jan 2017, 9:15 AM
Александр Филин
Александр Филин - avatar
2 Answers
+ 2
try #include <ctime> #include <cstdlib> #include <iostream> int main() { srand(time(0)); std::cout << (rand() % 5) + 1 << std::endl; return 0; } different numbers between 1-5 everytime u execute it
24th Jan 2017, 9:23 AM
Kawaii
Kawaii - avatar
+ 1
Try to first call the srand() function, with actual time as parameter: http://www.cplusplus.com/reference/cstdlib/rand/
24th Jan 2017, 9:20 AM
visph
visph - avatar