C Language Iteration Statements/Loops: for, while, do-while


  • /* all versions */
  • for ([expression]; [expression]; [expression]) one_statement
  • for ([expression]; [expression]; [expression]) { zero or several statements }
  • while (expression) one_statement
  • while (expression) { zero or several statements }
  • do one_statement while (expression);
  • do { one or more statements } while (expression);
  • // since C99 in addition to the form above
  • for (declaration; [expression]; [expression]) one_statement;
  • for (declaration; [expression]; [expression]) { zero or several statements }


Iteration Statement/Loops fall into two categories:

  • head-controlled iteration statement/loops
  • foot-controlled iteration statement/loops

Head-Controlled Iteration Statement/Loops

for ([<expression>]; [<expression>]; [<expression>]) <statement>
while (<expression>) <statement>
for ([declaration expression]; [expression] [; [expression]]) statement

Foot-Controlled Iteration Statement/Loops

do <statement> while (<expression>);