Loop and it’s types

by • 11/07/2011 • Old Pattern Computer NotesComments (0)634

LOOP

While writing a program it is necessary to repeat a part of a program for a number of times. The best solution for this is to use a loop it is a method which executes a part of the program repeatedly as specified by the programmer.

TYPES OF LOOPS

a) Pre-Test Loop

b) Post-Test Loop

a) PRE – TEST LOOP:

As its name indicates, checks the looping condition at the start of the loop if the condition is true the loop execution starts otherwise stops. This loop is used in a situation when part of program is to be repeated for a fixed number of times.

e.g., FOR …… NEXT.

b) POST – TEST LOOP:

This loop checks the looping condition at the end of loop and decides whether or not to continue the execution. This loop is used when a part of the program needs to be repeated until a specified condition is met.

e.g., WHILE …… WEND.

Pin It

Leave a Reply