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

Why always 41 ?

31st Aug 2017, 6:07 PM
harsh jaiswal
harsh jaiswal - avatar
2 Answers
+ 11
Because you forgotten to seed the built-in RNG algorithm using srand(). #include <iostream> #include <cstdlib> #include <ctime> int main() { srand(time(0)); std::cout << rand(); }
31st Aug 2017, 6:11 PM
Hatsy Rei
Hatsy Rei - avatar
+ 3
var answer = 42; --answer; ^^
31st Aug 2017, 7:09 PM
visph
visph - avatar