Rand() | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Rand()

#include <iostream> #include <cstdlib> using namespace std; int main() { cout << rand(); } whenever I run it shows 41 why?????

18th May 2017, 10:02 AM
CHETHAN
CHETHAN - avatar
3 Answers
+ 8
#include <ctime> etc int main() { srand(time(0)); etc etc
18th May 2017, 10:12 AM
jay
jay - avatar
+ 7
no seed seed with srand()
18th May 2017, 10:07 AM
jay
jay - avatar
+ 7
https://code.sololearn.com/cFxdiCUu5OG2/?ref=app have a look at this code. You might have to dig to find it. I am sure someone has a clearer example than this though
18th May 2017, 10:10 AM
jay
jay - avatar