What balance after the following code is executed?
int balance = 10;
while (balance >= 1) {
if (balance < 9)
continue;
balance = balance - 9;
}
A. -1
B. 0
C. 1
D. 2
E. The loop does not end
e Before the loop, balance is 10 . The loop-continuation-condition is true (10 >= 1). In the first iteration, balance is reduced to 1 . Since 1 >= 1 is true, the loop body is executed. Since balance < 9 is true, the continue statement is executed to skip the rest statement in the iteration. balance continues to be 1 and the continue statement is executed to skip the rest statement in the iteration. So the loop runs infinitely. So the correct answer to this question is E.
You might also like to view...
LCD stands for ________ display
A) lumens and crystal B) liquid crystal C) laser compact D) liquid cathode
Windows Internet Name Service (WINS) servers are not supported by Cisco routers.
Answer the following statement true (T) or false (F)