Analyze the following statement:
double sum = 0;
for (double d = 0; d < 10;) {
d += 0.1;
sum += sum + d;
}
a. The program has a compile error because the adjustment is missing in the for loop.
b. The program has a compile error because the control variable in the for loop cannot be of the double type.
c. The program runs in an infinite loop because d < 10 would always be true.
d. The program compiles and runs fine.
d In this loop, the loop initial action is d = 0, the continuation condition is d < 10, and the action-after-each-iteration is blank. Note that any of these three parts in the loop can be omitted. So, the loop is correct. The correction answer is (D).
You might also like to view...
A(n) ________ image is one that allows the colors and graphics of the background of the page to show through the image
Fill in the blank(s) with correct word
Which one of the following Button control names is a legal C# identifier?
a. Display Option 5 Button b. Exit! Button c. *Clear*Button* d. delete Record Button