Computer Science for IGCSE & O level - Algorithm Design And Problem Solving (Section 7 - No. 50)

What is the main difference between a pre-condition and a post-condition loop?
Pre-condition loops execute a block of code first, then check the condition; post-condition loops check the condition first.
Pre-condition loops check the condition before executing the loop, and post-condition loops check the condition after.
Pre-condition loops always run at least once, while post-condition loops might not run at all.
There is no difference; both loop types function the same way.

Explanation

A pre-condition loop first checks the condition, while a post-condition loop checks the condition after the loop body is executed.

Comments (0)

Advertisement