int varB;
do while (varA < 3)
{
for (varB = 1; varB < 3; varB +=1)
final = final * varB;
varA += 1;
}
the for loop needs opening and closing braces
a semicolon is required after the while loop
the while condition is in the wrong place
35. A posttest loop is also referred to as which of the following?
36. The do while statement ends with what character?
37. The code below prints 12 asterisks on the screen, one per line. Modify the code to print 2 lines containing 6 asterisks
each.
for (int outer = 1; outer <= 4; outer = outer + 1)
for (int inner = 1; inner <= 3; inner = inner + 1)
cout << “*” << endl;
38. Using a C++ do while statement, print five asterisks on the screen, one at a time, on the same line. Use the count
variable below as your counter variable. Advance the cursor to the next line when finished.
int count = 1;
39. Using a C++ for statement, print five asterisks on the screen, one at a time, on the same line. Use the count variable
below as your counter variable. Advance the cursor to the next line when finished.
40. The code below prints 15 asterisks on the screen, one per line. Modify the code to print 3 lines containing 5 asterisks
each.
for (int outer = 1; outer <= 5; outer = outer + 1)
for (int inner = 1; inner <= 3; inner = inner + 1)
cout << “*” << endl;
41. Write the C++ code using nested for loops that prints the product of the outer loop counter and the inner loop counter;
one per line. The outer loop counter should go from 1 to 10 and the inner loop counter should go from the value of the
outer loop counter to 10. Both counters should increment by 1. Use outer for the outer loop counter and inner for the inner
loop counter.
42. Why are posttest loops good for displaying a menu of items to the user?