Use the for loop to execute a block of statements a given number of times. - C Statement

C examples for Statement:for

Introduction

The general pattern for the for loop is:

for(starting_condition; continuation_condition ; action_per_iteration)
  loop_statement;
next_statement;

To display the numbers from 1 to 10.

Demo Code

#include <stdio.h>

int main(void){
  int count = 1;//from  w  w  w.  j  a v a2s.  c  o m
  for( ; count <= 10 ; ++count){
    printf("  %d", count);
  }
  printf("\nAfter the loop count has the value %d.\n", count);
  return 0;
}

Result


Related Tutorials