C Looping and Iteration

Looping & Iteration statements are used to execute the block of code repeatedly for a specified number of times or until it meets a specified condition. In C Programming Language we have following loop types.

The for loop statement

The for loop is used when we want to execute block of code known times.

Property Description
initialization Sets a counter variable
condition It test the each loop iteration for a condition. If it returns TRUE, the loop continues. If it returns FALSE, the loop ends.
increment Increment counter variable

The while loop statement

The while loop will execute a block of statement as long as a test expression is true.

The do…while loop statement

The do…while statement will execute a block of code and then test the condition for next iteration and executes next only if condition is true, block of code executes at least once.