Will the following program terminate?
int balance = 10;
while (true) {
if (balance < 9)
continue;
balance = balance - 9;
}
a. Yes
b. No
b Before the loop, balance is 10 . In the loop, balance becomes 1 . The loop-continuation-condition is always true. When balance < 9 is true, the continue statement is executed to skip the rest statement in the iteration. So the loop continues in an infinite loop. So, the correct answer is B.
Computer Science & Information Technology
You might also like to view...
The letters that follow the period at the end of a file name is called a(n) ________
Fill in the blank(s) with correct word
Computer Science & Information Technology
The NEVER function allows creation of logical statements in which it creates the opposite or reverse result
Indicate whether the statement is true or false.
Computer Science & Information Technology