previous | start | next

Syntax 6.1. The while Statement

  while (condition)
   statement

Example:

 
while (balance < targetBalance)
{
year++;
double interest = balance * rate / 100;
balance = balance + interest;
}

Purpose:

To execute a statement while a condition is true


previous | start | next