previous | start | next

Syntax 7.1: The while Statement

  while (condition)
   statement

Example:

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

Purpose:

To repeatedly execute a statement as long as a condition is true

previous | start | next