#include<iostream>
int main()
{
std::cout << "Enter two numbers:" << std::endl;
int v1 = 0, v2 = 0;
std::cin >> v1 >> v2;
std::cout << "The sum of " << v1 << " and " << v2 << " is " << v1 + v2 << std::endl;
return 0;
}
If the input given is 5 6
, it'll print "The sum of 5 and 6 is 11". But how does the istream
know when to stop?
Does it keeps on taking input if its an integer and stops if it gets another data type?
How does it assign the correct values of v1
and v2
?