66.9k views
1 vote
The ____________ is a posttest loop, which means it performs an iteration before testing its Boolean expression.

a. for loop
b. while loop
c. do-while loop
d. do-before loop

1 Answer

5 votes

Answer:

c. do-while loop

Step-by-step explanation:

In a do-while loop, the loop body is executed at least once before the Boolean expression is tested. This makes it a posttest loop, meaning that the test is performed after the loop body has executed at least once. In contrast, a pretest loop, such as a for loop or a while loop, tests the Boolean expression before executing the loop body.

The structure of a do-while loop is as follows:

```

do {

// loop body

} while (boolean expression);

```

The loop body is executed first, and then the Boolean expression is evaluated. If the expression is true, the loop body is executed again, and the process repeats until the expression is false. Because the loop body is guaranteed to execute at least once, a do-while loop is useful in situations where you want to ensure that a certain set of statements is executed before testing a condition.

User Amin Ba
by
8.8k points