Will the following program terminate?

int balance = 10;

while (true) {
if (balance < 9)
break;
balance = balance - 9;
}
a. Yes
b. No

a Yes. Before the loop, balance is 10 . The loop-continuation-condition is always true. In the first iteration, balance is reduced to 1 . In the second iteration, the break statement is executed since (balance < 9) is now true. The correct answer for this question is A.

Computer Science & Information Technology

You might also like to view...

Which interior intrusion detection system (IIDS) sensor uses heat radiation to detect intruders?

a. Ultrasonic. b. Microwave. c. Passive infrared. d. Dual-phenomenology.

Computer Science & Information Technology

Match the following commands to the corresponding descriptions.

1. who 2. who H 3. date 4. cal 2 5. passwd 6. man 7. [Ctrl-d] 8. [Ctrl-c] a: Command to change your password b: Lists users of the system c: Lists users and displays column headings d: Shows calendar for the second month of the current year e: On line system documentation f: Displays date and time g: The kill character h: The command to end a session (to log off)

Computer Science & Information Technology