-->

Facebook

Jasper Roberts - Blog

Tuesday, October 7, 2014

Basic of Looping Structures

-   In certain situation in programming, statement(s) are required to be repeated for fixed number of times or till certain condition is satisfied.

-   C language provides looping structures so that we need not to write those statement(s) again and again in our program. If the
language does not provide looping structures then we will have to write those statement(s) again and again in our program.

-   And the program will becomes very lengthy, unmanageable and more typing.

-   In that case, we will have no option. But C language provides the looping structures for those cases.


Looping Structures are:
1. while loop,
2. do…while loop,
3. for loop.


Types of loops

-      There are two types of loop structures depending on where the condition is checked.
  1.  Entry control loop
  2. Exit control loop

1. Entry control loop

-   In entry control loop, the condition is written first and checked. Till the condition is true, it will execute the body of statement(s).

-   While loop is entry control loop.

-   Flow chart


flow chart of while loop
while loop




   2. Exit control loop

   -   In exit control loop, the body of statement(s) is written first and then condition is written.
   
   -   This means that body of statement(s) in exit control loop will be executed at least once.

   - do...while loop is exit control loop
   -   Flow chart:
flow chart of do while loop
do ... while loop

DOWNLOAD          DOWNLOAD
download nested if else statement             download nested if else statement

No comments:

Post a Comment