What is sum after the following loop terminates?
int sum = 0;
int item = 0;
do {
item++;
if (sum >= 4)
continue;
sum += item;
}
while (item < 5);
a. 6
b. 7
c. 8
d. 9
e. 10
a In this loop, when sum >= 4, the continue statement is executed to exit the current iteration so the next statement sum += item after the if statement will not be executed. The loop keeps adding item to sum for item 1, 2, 3, and so on. So sum is 1, 2, and 6 . When sum is 6, sum >=4 is true, the continue statement is executed to skip the rest of the iteration. When the loop ends, sum is still 6 . So, the correct answer is A.
You might also like to view...
Pressing and holding [Alt] (Win) or [option] (Mac) when making a selection removes pixels from the existing selection.
Answer the following statement true (T) or false (F)
A(n) _________ is a device that is designed to be used in conjunction with a company network instead of usinglocal hard drives for storage. A. network hub B. thin client C. coupled modem D. enterprise router
Fill in the blank(s) with the appropriate word(s).
What GPO policy will take precedence over all other GPO policies when they are being applied?
A. The policy selected by the administrator will take precedence B. The first policy applied takes precedence C. The policy with a value of 100 will take precedence D. The last policy applied takes precedence
Operating systems typically contain a disk ________ or optimization utility, which will reorganize files and fragments to place related ones nearer to each other.
A. compression B. defragmentation C. formatting D. cleanup