Loop Construcs

OVERVIEW:

We often encounter problems whose solutions may require executing a statement or a set of statements repeatedly. In such situations, we need a structure that would allow repeating a set of statements up to fixed number of times or until a certain criterion is satisfied. In C, Loop statements fulfill this requirements. 
             "Iteration is the third type of program control structure (sequence, selection, iteration), and the repetition of statements in a program is called a loop.There are three loop control statements in C, these are:
  • while
  • do-while
  • for

While Statement:

The while loop keeps repeating associated statements until the specified condition becomes false. This is useful where the programmer does not know in advance how many times the loop will be traversed. The syntax of the while statement is:
  
            while (condition)
            {
                     statement(s)
             }

The condition in the while loop controls the loop iteration.The statements, which are executed when the given condition is true, form the body of loop. If he condition is true, the body of the loop is executed. As soon as i becomes false, the loop terminates immediately.
























Comments

Popular posts from this blog

Data Base Design Process

Data Base

Data Integrity And Normalization