Why does the rand() happens to be different? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why does the rand() happens to be different?

I'm learning C++ but one question Why is this code #include <iostream> #include <cstdlib> using namespace std; int main() { cout << rand(); } Is different in the output that Sololearn did

14th Nov 2018, 1:19 PM
Philly Deck
Philly Deck - avatar
3 Answers
+ 2
It returns random value😃 https://www.sololearn.com/learn/CPlusPlus/1638/?ref=app If you want to know the algorithm behind it. just reply me
14th Nov 2018, 1:28 PM
Roneel
Roneel - avatar
+ 1
Roneel is right,it will generate any random number so it will always differ when compiled ..
14th Nov 2018, 3:24 PM
Mensch
Mensch - avatar
0
Thanks guys it really appreciated
14th Nov 2018, 9:01 PM
Philly Deck
Philly Deck - avatar