Explain each of the following loops. Correct any problems you detect.
(a)
1 2 3 4 5 6
doint v1, v2;
cout << "Please enter two numbers to sum:";
if (cin >> v1 >> v2)
cout << "Sum is: " << v1 + v2 << endl;
while (cin);
But I do now understand what he meant by the cin condition
1 2 3 4 5 6
do {
int v1, v2;
cout << "Please enter two numbers to sum:";
if (cin >> v1 >> v2)
cout << "Sum is: " << v1 + v2 << endl;
} while (cin); // how would you fix the cin condition?
Take int v1 and v2 out of the if statement. it should look like this:
cout << "Please enter two numbers to sum:";
cin >> v1 >> v2;
cout << "Sum is: " << v1 + v2 << endl;