Rewrite the programs TestBreak and TestContinue in Listings 1 and 2 without using break and continue.
Listing 1


The program in Listing 2 adds integers from 1 to 20 in this order to sum until sum is greater than or equal to 100. Without the if statement (line 9), the program calculates the sum of the numbers from 1 to 20. But with the if statement, the loop terminates when sum becomes greater than or equal to 100. Without the if statement, the output would be:
Listing 2




The program in Listing 2 adds integers from 1 to 20 except 10 and 11 to sum. With the if statement in the program (line 8), the continue statement is executed when number becomes 10 or 11. The continue statement ends the current iteration so that the rest of the statement in the loop body is not executed; therefore, number is not added to sum when it is 10 or 11. Without the if statement in the program, the output would be as follows:

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.