Page 63 - 1
P. 63
IF... THEN... ELSE Statement
IF... THEN... ELSE statement is used to make a statement. If the condition given after IF is
true then the statement given after THEN will be executed.
Syntax
IF <Condition> THEN <Statement> ELSE <Statement>
Example
IF A > 10 THEN PRINT A ELSE PRINT “Wrong value”
ELSEIF With IF... THEN Statement
ELSEIF statement is used when we want to give more than one condition.
Syntax
IF <Condition 1>
THEN <Action 1>
ELSEIF <Condition 2>
THEN <Action 2>
ELSEIF <Condition 3>
THEN <Action 3>
ELSE
<Condition 4>
ENDIF
Example
IF A > 10
THEN B = B + 1
ELSEIF A < 10
THEN C = C + 1
ELSEIF A = 10
THEN D = D + 1
ELSE
PRINT “Try again”
ENDIF
CLS Statement
CLS statement is used to clear the output screen. It is used mostly at the starting of a new
program to remove the output of the previous program.
Syntax
CLS
Example
PRINT “My name is Amrit.”
CLS
63