For Loop in C – Tutorialpath

For Loop in C

A loop is used for executing a block of statements repeatedly until a given condition returns false.

C For loop

This is one of the most frequently used loop in C programming.

Syntax of for loop:

Flowchart Diagram of For loop

Step 1: First initialization happens and the counter variable gets initialized.
Step 2: In the second step the condition is checked, where the counter variable is tested for the given condition, if the condition returns true then the C statements inside the body of For Loop in C  gets executed, if the condition returns false then the for loop gets terminated and the control comes out of the loop.
Step 3: After successful execution of statements inside the body of loop, the counter variable is incremented or decremented, depending on the operation (++ or –).

Example: For loop


Loops: Loops are used in programming to repeat a specific block of code. After reading this tutorial, you will learn how to create while and do…while loop in C programming.

Do while loop in c: The do. . .while loop is similar to the while loop with one important difference. The body of do. . .while loop is executed once, before checking the test expression. Hence, the do. . .while loop is executed at least once.

Leave a Reply

Your email address will not be published.