for loop
The for loop in C language is also used to iterate the statement or a part of the program several times, like while and do-while loop
But, we can initialize and increment or decrement the variable also at the time of checking the condition in for loop. Unlike do while loop, the condition or expression in for loop is given before the statement, so it may execute the statement 0 or more times.When use for loop
For loop is better if number of iteration is known to the programmer. Syntax of for loop
for(initialization;condition;incr/decr) { //code to be executed }
Flowchart of for loop

Example of for loop
#include <stdio.h> void main( ) { int i = 0; for(i = 1;i<= 12; i++) { printf("%d ",i); } } Output: 1 2 3 4 5 6 7 8 9 10 11 12
#include <stdio.h> void main( ) { int i = 1,number = 0; printf("Enter a number: "); scanf("%d",&number); for(i = 1; i<= 6; i++) { printf("%d ",(number*i)); } } Output: Enter a number: 4 4 8 12 16 20 24
Infinitive for loop
If you don't initialize any variable, check condition and increment or decrement variable in for loop, it is known as infinitive for loop. In other words, if you place 2 semicolons in for loop, it is known as infinitive for loop.for(;;) { printf("infinitive for loop example by Catchmecoder"); }