How to use for loop in C Programming


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.

#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("%d\n", i);


   return 0;


Leave a Reply

Your email address will not be published. Required fields are marked *