For loop is also a type of repetition structure. This repetition structure is simpler in syntax as compared with other 2 loops because all four loop conditions can be defined in single line. Following simple program explains how to use for loop to print numbers from 1-10.
[js]
#include <stdio.h>
int main(void){
// for loop is a type of repetition structure in C programming. In any loop you need to fulfill following 4 conditions
for(int i=1; i<=10; i++){ // here in one line we defined control variable i (condition 1),
//assigned initial value to control variable i (condition 2), defined loop termination condition (condition 3)
//and incremented the control variable (condition 4)
printf("%dn", i);
}
return 0;
}
[/js]