while (response != 1 && response != 2 && response != 3)
{
cout << Enter 1, 2, or 3: ;
cin >> response;
}
6. Rewrite the following code segment using a While loop.
cin >> ch;
if (cin)
do
{
cout << ch;
cin >> ch;
} while (cin);
7. Rewrite the following code segment using a For loop.
sum = 0;
count = 1;
while (count <= 1000)
{
sum = sum + count;
count++;
}
8. Rewrite the following For loop as a While loop.
for (m = 93; m >= 5; m--)
cout << m << << m * m << endl;
9. Rewrite the following For loop using a Do-While loop.
for (k = 9; k <= 21; k++)
cout << k << << 3 * k << endl;
10. Write a value-returning function that accepts two int parameters, base and component, and returns the value of base raised to the exponent power. Use a For loop in your solution.
11. Make the logic of the following loop easier to understand by using an infinite loop with break statements.
sum = 0;
count = 1;
do
{
cin >> int1;
if ( !cin || int1 <= 0)
cout << Invalid first integer.;