previous | start | next

Syntax 5.1. The if Statement

  if(condition)
   statement

if
(condition)
   statement

else
   statement

Example:

 
if (amount <= balance)
balance = balance - amount;

if (amount <= balance)
balance = balance - amount;
else
balance = balance - OVERDRAFT_PENALTY;

Purpose:

To execute a statement when a condition is true or false



previous | start | next