We could have written the loop to manage the interaction with the user as a do while (§ 5.4.4, p. 189) loop. Rewrite the loop to use a do while. Explain which version you prefer and why.
§ 5.4.4 (p. 189)
Exercise 5.18
Explain each of the following loops. Correct any problems you detect.
(a) do
int v1, v2;
cout << "Please enter two numbers to sum:" ;
if (cin >> v1 >> v2)
cout << "Sum is: " << v1 + v2 << endl;
while (cin);
(b) do {
// ...
} while (int ival = get_response());
(c) do {
int ival = get_response();
} while (ival);
Exercise 5.19
Write a program that uses a do while loop to repetitively request two strings from the user and report which string is less than the other.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.