# Iteration Control Structure

posted by .

Design a program that models the worm's behavior in the following scenario:
A worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apple by its own body length until the worm is close enough to enter the apple. The worm can enter the apple when it is within a body length of the apple.

• Iteration Control Structure -

Design a program that models the worm's behavior in the following scenario:
A worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apple by its own body length until the worm is close enough to enter the apple. The worm can enter the apple when it is within a body length of the apple

• Iteration Control Structure -

variable distance \\distance to the apple
variable count \\ count the moves of the worm towards the apple
variable body_length \\ the length of the worm

input distance
Display {The distance between the worm and apple is “ “.}

Input body_length
Display {The worm’s length is “ “.}

while (distance >= body_length){
distance = distance - body_length
count = count +1
}

The code in the while loop (enclosed by the {}) will keep repeating until the statement in the
brackets is true. So while the distance is greater than or equal to the length of the worm it will repeat the code in the loop.

The code inside the loop has two parts as you can see. Because it always moves forward by its own body length the distance to the apple has the body length taken away from it. The count variable keeps track of how many moves the worm has taken. Hence it has 1 added to it. The loop will stop when the worm is close enough to enter the apple. It does not count the move of entering the apple.

• Iteration Control Structure -

THE ITERATION CONTROL STRUCTURE HAS 2 TYPES THE dO-UNTIL STRUCTURE AND THE DO-WHILE STRUCTURE.ITERATION{LOOP}CONTROL STRUCTURE IS A STRUCTURE IN WHICH A PROCESS MAY BE REPEATED AS LOMG AS ACERTEIN CONDITION REMAINS TRUE OR REMAINS FALSE .
IN THE DO UNTIL SRUCTURE EXIT FROM THE LOOP IS DONE AT THE END OF THE LOOP aND ALSO THE LOOP STATEMENT ARE EXECUTED AT LEAST ONCE BECAUSE THEY PERFORMED BEFORE THE PROGRAM CHECKS WETHER TO STOP OR NOT.
IN THE DO WHILE STRUCTURE ,THE LOOP EXIT CONDITION IS PLACED AT THE BEGGINING OF THE LOOP .

• Iteration Control Structure -

pak u! mga bobo

• Iteration Control Structure -

potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo potang ina niyo

• Iteration Control Structure -

This is simple come on people?!?!?

• Iteration Control Structure -

iteration control structure is a structure in which a process maybe repeated as long as certain condition remains true or false.

• Iteration Control Structure -

with this program how would it change if the worm was to enter the apple