Write program a qbasic to input two numbers andtl display the largest number
Answers
Answer:
91. WAP to enter any two numbers and display the greater one.
REM
CLS
INPUT “ENTER ANY TWO NUMBERS”; A, B
IF A > B THEN
PRINT A; “IS GREATER”
ELSE
PRINT B; “IS GREATER”
END IF
END
USING SUB PROCEDURE
DECLARE SUB GREAT (A, B)
CLS
INPUT “ENTER ANY TWO NUMBERS”; A, B
CALL GREAT (A, B)
END
SUB GREAT (A, B)
IF A > B THEN
PRINT A; “IS GREATER”
ELSE
PRINT B; “IS GREATER”
END IF
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION GREAT (A, B)
INPUT “ENTER ANY TWO NUMBERS”; A, B
PRINT “THE GREATER NUMBER IS”; GREAT (A, B)
END
FUNCTION GREAT (A, B)
IF A > B THEN
GREAT = A
ELSE
GREAT = B
END IF
END FUNCTION
92. WAP to enter any two numbers and display the smaller one.
REM
CLS
INPUT “ENTER ANY TWO NUMBERS”; A, B
IF A < B THEN
PRINT A; “IS SMALLER”
ELSE
PRINT B; “IS SMALLER”
END IF
END
USING SUB PROCEDURE
DECLARE SUB SMALL (A, B)
CLS
INPUT “ENTER ANY TWO NUMBERS”; A, B
CALL SMALL (A, B)
END
SUB SMALL (A, B)
IF A < B THEN
PRINT A; “IS SMALLER”
ELSE
PRINT B; “IS SMALLER”
END IF
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION SMALL (A, B)
INPUT “ENTER ANY TWO NUMBERS”; A, B
PRINT “THE SMALLER NUMBER IS”; SMALL (A, B)
END
FUNCTION SMALL (A, B)
IF A < B THEN
SMALL = A
ELSE
SMALL = B
END IF
END FUNCTION
93. WAP to enter any three numbers and display the greatest one.
REM
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
IF A > B AND A > C THEN
PRINT A; “IS GREATEST”
ELSEIF B > A AND B > C THEN
PRINT B; “IS GREATEST”
ELSE
PRINT C; “IS GREATEST”
END IF
END
USING SUB PROCEDURE
DECLARE SUB GREAT (A, B, C)
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
CALL GREAT (A, B, C)
END
SUB GREAT (A, B, C)
IF A > B AND A > C THEN
PRINT A; “IS GREATEST”
ELSEIF B > A AND B > C THEN
PRINT B; “IS GREATEST”
ELSE
PRINT C; “IS GREATEST”
END IF
END SUB