0

When assigning multiple variables with cin, are they all assigned with the same value?

For instance, cin >> x >> y; Does this give you two instances of input to assign different values to x and y, or does it take one input and assign it to both x and y? Thanks, M

2nd Feb 2017, 2:27 PM
theora
theora - avatar
2 ответов
0
it's give you different values of x and y
2nd Feb 2017, 3:17 PM
Hritik Bhattacharya
0
Thanks Hritik. For anyone wondering, I messed around and if you type in something and hit enter, the console waits for you to enter a second input. It also works if you put a space between the two inputs, for example: int x, y; cout << "Enter two integers "; cin >> x >> y; If you enter "5 4" (note the space between) then the 5 is assigned to x and the 4 to y. Without the space, x is assigned 54.
2nd Feb 2017, 9:45 PM
theora
theora - avatar