C - A for Loop with No Body

Description

A for Loop with No Body

Demo

#include <stdio.h> 

int main() /*from   w  ww  .  ja  v a  2 s . c om*/
{ 
      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