KnowledgeBoat Logo

Computer Studies

What are the different types of conditional statements used in QBASIC programming? Explain.

QBASIC: Conditional Statements

26 Likes

Answer

There are two conditional statements used in QBASIC. They are as follows:

IF - THEN statement: This statement checks only the 'true' part of the program and comes to an end. It is used to check a condition and then perform any task based on the given condition.

Syntax:

IF  THEN  

Example:

IF A > 0 THEN PRINT "A IS POSITIVE"

IF - THEN with ELSE statement: This statement performs either of the two specified tasks based on a given condition whether it is 'true' or 'false'.

Syntax:

IF  THEN  ELSE 

Example:

LET A = 5
IF A >= 0 THEN PRINT "A IS POSITIVE" ELSE PRINT "A IS NEGATIVE" 
  1. IF - ELSEIF statement: This statement allows us to check a secondary condition if the first condition is 'False'.

Syntax:

IF  THEN  
ELSEIF  THEN 
END IF

Example:

LET A=5
IF A >= 0 THEN PRINT "A IS POSITIVE" 
ELSEIF A < 0 THEN PRINT "A IS NEGATIVE"
END IF

Answered By

10 Likes


Related Questions