previous | start | next

Syntax 7.2: The for Statement

  for (initialization; condition; update)
   statement

Example:

  for (int i = 1; i <= n; i++)
{
   double interest = balance * rate / 100;
   balance = balance + interest;
}

Purpose:

To execute an initialization, then keep executing a statement and updating an expression while a condition is true


previous | start | next