C loops

If you have some situation where you have to executed some set of statements multiple time. There you need loop. In looping set of statements are executed untill the loop termination condition is satisfied.

A loop consist of two segments. One for body and other for condition.

if condition is true then body part of loop will be executed otherwise loop will be terminated.

C programming provides following loop statements:

1. for

2. while

3. do while

Loop Name




For( exp1;exp2 or condition;exp3){ 


……;  }

exp1-> Variable initialization

exp2-> Conditon checking

exp3-> increment or decrement



Statements; }

relational operators are used to check conditions

do .. while

do { 



do while loop executed atleast one time befor condition check.

Examples :

For loop : Printing 1 to 10 numbers

While loop: Adding 1 to 10 numbers

Do while loop: printing even nos between 1 to 10