Home QBASIC C Java HTML
  • More Courses
  • MCQs
  • Blog Download
  • Tools
  • Contact

    Contents

    IF ... THEN Statement


    It is the most simple form of the control statements which executes a block of statements only if the given expression or condition is true. If the condition is false, then the IF block will skipped and execution continues with the rest of the program.

    Syntax: 

    IF [conditional expression] THEN [statement block]
    OR
    IF [conditional expression] THEN
    [statement]
    END IF

    Example: 1

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

    Example: 1

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

     


    272