``

prev Menu next

IF ～ END IF ☆☆☆

(1)

    IF logical_expression THEN
      ………
    END IF

If logical_expression is true, the part ……… shall be executed.
The part ……… can consist of multiple statements.
Example.

      10 ! Solve a quadratic equation.
      20 INPUT a, b, c
      30 LET D=b^2-4*a*c
      40 IF D>=0 THEN
      50    PRINT (-b + SQR(D))/(2*a), (-b-SQR(D))/(2*a)
      60 END IF
      70 END

(2)

    IF logical_expression THEN
      ………1
    ELSE
      ………2
    END IF

if logical_expression is true, the part ………1 shall be executed,
otherwise the part ………2 shall be executed.
Example.

      10 ! Solve a quadratic equation.
      20 INPUT a, b, c
      30 LET D=b^2-4*a*c
      40 IF D>=0 THEN
      50    PRINT (-b + SQR(D))/(2*a), (-b-SQR(D))/(2*a)
      60 ELSE
      70    PRINT "no solution"
      80 END IF
      90 END