If statements enables us to make a comparison between two values.
General form:
IF condition-1 statement-1
Where the condition-1 may be one of the following
The IF statement is normally terminated by a period. This statement at first evaluates condition-1 which may be either true or false. If the condition is true, the statements following the condition are executed and the control is then passed to the next sentence after IF (provided that the statement before the period does not transfer the control to elsewhere in the program). If the condition is false, the control is transferred directly to the next sentence without executing the statements following condition-1.
The condition-1 as shown above is known as a relational condition.
Example:
IF A IS GREATER THAN B MOVE 3 TO X.
If A has a value 4 and B has a value 2, then 3 will be moved to X.
No comments:
Post a Comment