Structure of for Loop

The for loop follows a very structured approach where it begins with initializing a condition then checks the condition and in the end executes conditional statements followed by an updation of values.

  1. Initialization: This step initializes a loop control variable with an initial value that helps to progress the loop or helps in checking the condition. It acts as the index value when iterating an array or string.
     
  2. Check/Test Condition: This step of the for loop defines the condition that determines whether the loop should continue executing or not. The condition is checked before each iteration and if it is true then the iteration of the loop continues otherwise the loop is terminated.
     
  3. Body: It is the set of statements i.e. variables, functions, etc that is executed repeatedly till the condition is true. It is enclosed within curly braces { }.
     
  4. Updation: This specifies how the loop control variable should be updated after each iteration of the loop. Generally, it is the incrementation (variable++) or decrementation (variable–) of the loop control variable.

C for Loop

In C programming, loops are responsible for performing repetitive tasks using a short code block that executes until the condition holds true. In this article, we will learn about for loop in C.

Similar Reads

for Loop in C

The for loop in C Language provides a functionality/feature to repeat a set of statements a defined number of times. The for loop is in itself a form of an entry-controlled loop....

Syntax of for Loop

for(initialization; check/test expression; updation) { // body consisting of multiple statements }...

Structure of for Loop

The for loop follows a very structured approach where it begins with initializing a condition then checks the condition and in the end executes conditional statements followed by an updation of values....

How for Loop Works?

The working of for loop is mentioned below:...

Flowchart of for Loop

C for Loop Flow Diagram...

Example of for loop

The following program illustrates how to use for loop in C:...

Nested for loop in C

...

Special Conditions

C provides the feature of a nested loop where we can place a loop inside another loop....

Advantages of for Loop

1. for loop without curly braces...

Disadvantages of for Loop

...

Conclusion

...

FAQs on for loops in C

There are certain advantages of using for loops in C as mentioned below:...