18.7k views
1 vote
What is an example of a condition controlled loop? What would the syntax look like?

User Natxty
by
4.9k points

1 Answer

2 votes

Answer:

The answer to this question is given below in the explanation section.

Step-by-step explanation:

WHILE loops and DO WHILE loops are called the condition controlled loops. The execution of these loops depends on a certain condition, when the condition is true, the loop body will be executed and when the condition becomes false, the loop body will not be executed. the major difference between both loops is given below.

In the WHILE loop, the condition is checked at the beginning of the loop whereas in the do-while loop condition is checked at the end of the loop and, in the do-while loop, the loop body is executed at least once.

The syntax of the while loop is given below

while (condition) {

// code block to be executed

}

The syntax of do-while loop is given below

do {

// code block to be executed

}

while (condition);

User Callie
by
5.8k points