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.

Computer Science & Information Technology

You might also like to view...

Answer the following statements true (T) or false (F)

1. A direct access file is also known as a random access file. 2. Virtually all operating systems follow the same set of rules for naming files. 3. In order for a program to work with a file on the computer's disk, the program must create a file object using code statements. 4. To create file objects, you will need to include the using System.IO namespace at the top of your programs.

Computer Science & Information Technology

The ____ Tool samples an existing color in a graphic or panel to assign a new foreground or background color.

a. Color Replacement b. Color Sampler c. Info d. Eyedropper

Computer Science & Information Technology

Syndicated content is delivered to Web sites and applications via a Web feed.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

To change a bulleted list to a numbered list, you must first remove the bulleted list format, and then apply the numbered list format.

a. true b. false

Computer Science & Information Technology