# QBasic Programming

## WAP to enter any three numbers and display the greatest, smallest and the middle number

USING SUB PROCEDURE

DECLARE SUB GREAT (A, B, C)
DECLARE SUB MIDDLE(A, B, C)
DECLARE SUB SMALL (A, B, C)
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
CALL GREAT (A, B, C)
CALL MIDDLE (A, B, C)
CALL SMALL (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

SUB SMALL (A, B, C)
IF A < B AND A < C THEN
S = A
ELSEIF B < A AND B < C THEN
S = B
ELSE
S = C
END IF
PRINT “THE SMALLEST NUMBER IS “; S
END SUB
SUB MIDDLE (A, B, C)
IF A > B AND A < C OR A < B AND A > C THEN
PRINT A; “IS MIDDLE NUMBER”
ELSEIF B > A AND B < C OR B < A AND B > C THEN
PRINT B; “IS MIDDLE NUMBER”
ELSE
PRINT C; “IS MIDDLE NUMBER”
END IF
END SUB

USING FUNCTION  PROCEDURE

DECLARE FUNCTION GREAT (A, B, C)
DECLARE FUNCTION MIDDLE(A, B, C)
DECLARE FUNCTION SMALL (A, B, C)
CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
GR = GREAT (A, B, C)
MI = MIDDLE (A, B, C)
SM = SMALL (A, B, C)
PRINT “THE GREATEST NUMBER IS “; GR
PRINT “THE MIDDLE NUMBER IS “; MI
PRINT “THE SMALLEST NUMBER IS “; SM
END

FUNCTION GREAT (A, B, C)
IF A > B AND A > C THEN
G = A
ELSEIF B > A AND B > C THEN
G = B
ELSE
G = C
END IF
GREAT = G
END FUNCTION

FUNCTION MIDDLE (A, B, C)
IF A > B AND A < C OR A < B AND A > C THEN
M = A
ELSEIF B > A AND B < C OR B < A AND B > C THEN
M = B
ELSE
M = C
END IF
MIDDLE = M
END FUNCTION

FUNCTION SMALL (A, B, C)
IF A < B AND A < C THEN
S = A
ELSEIF B < A AND B < C THEN
S = B
ELSE
S = C
END IF
SMALL = S
END FUNCTION