Saturday, 22 December 2018

LOOPING STATEMENTS


LOOPING STATEMENTS :
                        When a single statement or a group of statements  executing again and again in a program i.e. in an iterative way, such type of processing is called Loop. These are classified into two parts:  a. body of the loop
                        B .control of the loop
                                The control loop statements tests certain conditions and then directs the repeated execution of the statements contained in the body of the loop. Mainly control loop are categorized into two parts: They are:
                                                  1. Entry control loop
                                      2. Exit control loop
1. Entry control loop:
                        In an entry control loop, first the condition is checked, if it is true, then body of the loop is executed otherwise the control is moved out of the loop i.e. we can exit from the loop when the condition becomes false.
                        Entry control loop is also called base loop. The “while” and “for” are the examples of entry control loop. The flow chart is as shown below:
2. Exit control loop:

                In an exit control loop, first body of the loop is executed and then condition is checked. If the condition is true, then again the body of the loop is executed. If the condition is false, then control will move out from the loop.
                Exit control loop is also called derived loop. The “ do-while “ statement is an example of exit control loop. The flow chart is shown below:


No comments:

Post a Comment