Counter-controlled
Entry-controlled
Exit-controlled
Accumulator-controlled
Answer is Right!
Answer is Wrong!
The correct answer is: A. Counter-controlled
A counter-controlled loop is a loop whose
processing is controlled by a counter. The counter is initialized to a value, and then it is incremented or decremented each time the loop body is executed. The loop terminates when the counter reaches a specified value.For example, the following code shows a counter-controlled loop that prints the numbers from 1 to 10:
int i = 1;
while (i <= 10) {
System.out.println(i);
i++;
}
In this example, the counter is initialized to 1, and then it is incremented each time the loop body is executed. The loop terminates when the counter reaches 11.
The other options are incorrect because they do not describe a loop whose processing is controlled by a counter.
- Option B, entry-controlled loop, is a loop that is entered only if a certain condition is true.
- Option C, exit-controlled loop, is a loop that terminates when a certain condition is true.
- Option D, accumulator-controlled loop, is a loop that accumulates a value over time.