IF ... THEN .... ELSE Statement


It is also a common control statement which is used to execute the multiple statements depending on the condition. It is also called two way decision statement. In this statement if the condition is true the the statements after THEN will be executed and if the condition is false, the statements in the ELSE block will be executed.

Syntax: 

IF [conditional expression] THEN
[statement 1]
ELSE
[statement 2]
END IF

Example 1

CLS
INPUT "Enter your marks "; m
IF m >= 35 THEN
     PRINT "You are passed !!"
ELSE
     PRINT "You are failed .."
END IF
END

Example 1

CLS
INPUT "Enter a number "; n
IF n MOD 2 = 0 THEN
     PRINT "Even Number"
ELSE
     PRINT "Odd Number"
END IF
END
 

  3150