you can see the output is a random number result from cin >> number;
, but when I use visual studio or eclipse doesn't show me the same output which is the random number number=-1219862963
1 2 3 4 5 6 7 8 9 10 11
#include <iostream>
usingnamespace std;
int main(void) {
int number;
cin >> number;//this is generate a random number but I am not sure if I am right about this.
cout << "You typed the number " << number << endl;// this should show me the number but it didn't.
cin.get ();
return 0;
}
//this is generate a random number but I am not sure if I am right about this.
You're wrong about this.
It fetches a value from the input. typically, from the keyboard.
When using ideone, because you don't have access to the keyboard (because it's running on a server somewhere on the internet), the input is instead gathered from you before you run the program. See the button marked "stdin", on the first page ( https://ideone.com/ ) ? Push it. Then you can enter the input for cin.
If you don't supply anything, ideone will supply something for you. Could be anything. It's not random.
Presumably if you don't supply any input, the cin >> will fail with an end-of-file condition and number will be unchanged. Since it was not initialised, it contains garbage.