Conditional Statements

if
An if statement is a control statement that executes the statement after it only if the condition is true.

Syntax:
if( <conditional expression> )
<statement when true>;

Example 1:
// this is initialized with 10,000 then requested for input
input numeric var MonthlyRate = 10000;
output numeric var DailyRate = MonthlyRate / 20;
if( DailyRate < 300 )
error ‘Daily rate is below the minimum wage’;

else
An else statement is a control statement that executes the statement only when the if condition is false.

Syntax:
if( <conditional expression> )
<statement when true>;
else
<statement when false>;

Example 1:
// this is initialized with 10,000 then requested for input
input numeric var MonthlyRate = 10000;
output numeric var DailyRate = MonthlyRate / 20;
if( DailyRate < 300 )
error ‘Daily rate is below the minimum wage’;
else
return DailyRate;