C - A for Loop with No Body

Description

A for Loop with No Body

Demo

#include <stdio.h> 

int main() /*  w  w w .  ja v  a 2s .  c  o m*/
{ 
      int x; 

      for(x=0;x<10;x=x+1,printf("%d\n",x)) 
          ; 
      return(0); 
}

Result

In the example, the semicolon is placed on the line after the for statement.

Two items are placed in the for statement's parentheses, both separated by a comma.

Related Example