What will be displayed when the following code is executed?
int number = 6;
while (number > 0) {
number -= 3;
System.out.print(number + " ");
}
a. 6 3 0
b. 6 3
c. 3 0
d. 3 0 -3
e. 0 -3
c number is 6 before the loop. In the first iteration, number is reduced to 3 . In the second iteration, number is reduced to 0 . The loop is now finished. The loop body is executed 2 times for number 6 and 3 . Since number is reduced by 3 before the print statement. 3 and 0 and displayed. So, the correct answer is C.
You might also like to view...
You can type and format comments in the ____ in Normal view.
A. Outline tab B. Slide pane C. Notes pane D. Slides tab
Discuss the considerations when editing a PowerPoint 2010 presentation in older versions of PowerPoint.
What will be an ideal response?
The Windows Registry is divided into six main keys
Indicate whether the statement is true or false.
In Query Design View, the query design ____________________ shows you the fields that you have requested for the query.
Fill in the blank(s) with the appropriate word(s).