why it always give output 41 in try yourself box..??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why it always give output 41 in try yourself box..???

1st Sep 2016, 7:03 AM
Sandy Kine
Sandy Kine - avatar
2 Answers
+ 3
Please post the code next time so people know what you are talking about. #include <iostream> #include <cstdlib> using namespace std; int main() { cout << rand(); } The answer to your question lies in the next lessons: you have to use srand to initialize the seed. Placing srand(time(0)) before the call will fix your problem.
1st Sep 2016, 7:36 AM
Zen
Zen - avatar
0
thnx Mr Zen....
1st Sep 2016, 3:17 PM
Sandy Kine
Sandy Kine - avatar