next up previous
Next: Common errors in writing Up: Unit 06 Previous: Example of while loop:

Characteristic elements in the design of a loop

initialization
while (condition) {
  operation
  next step
}

Once we have designed the loop, we have to check its proper termination. In particular, we have to check that the execution of the loop statements can modify the value of the condition in such a way that it becomes false.

Example: The statement multiplicator--; can cause the condition (multiplicator > 0) to become false, provided multiplicator is a positive integer number.


next up previous
Next: Common errors in writing Up: Unit 06 Previous: Example of while loop: