# QBasic Programming

## Enter any three numbers and display its sum, product and average

REM PROGRAM TO DISPLAY SUM, PRODUCT AND AVERAGE  OF THREE NUMBERS
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
INPUT “ENTER THIRD NUMBER”; C
S = A + B + C
P = A * B * C
AV = (A + B + C) / 3
PRINT “SUM OF THREE NUMBERS”; S
PRINT “PRODUCT OF THREE NUMBERS”; P
PRINT “AVERAGE OF THREE NUMBERS”; AV
END

USING SUB PROCEDURE

DECLARE SUB SUM (A, B, C)
DECLARE SUB PROD (A, B, C)
DECLARE SUB AVERAGE (A, B, C)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
INPUT “ENTER THREE NUMBERS”; C
CALL SUM(A, B, C)
CALL PROD(A, B, C)
CALL AVERAGE(A, B, C)
END

SUB SUM (A, B, C)
S = A + B + C
PRINT “SUM OF THREE NUMBERS”; S
END SUB

SUB PROD (A, B, C)
P = A * B * C
PRINT “PRODUCT OF THREE NUMBERS”; P
END SUB

SUB AVERAGE (A, B)
AV = (A + B + C) / 3
PRINT “AVERAGE OF THREE NUMBERS”; AV
END SUB
USING FUNCTION PROCEDURE

DECLARE FUNCTION SUM (A, B, C)
DECLARE FUNCTION PROD (A, B, C)
DECLARE FUNCTION AVERAGE (A, B, C)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
INPUT “ENTER THIRD NUMBER”; C
S = SUM(A, B, C)
P = PROD(A, B, C)
AV = AVERAGE(A, B, C)
PRINT “SUM OF THREE NUMBERS”; S
PRINT “PRODUCT OF THREE NUMBERS”; P
PRINT “AVERAGE OF THREE NUMBERS”; AV

FUNCTION SUM (A, B, C)
SU = A + B + C
SUM = SU
END FUNCTION

FUNCTION PROD (A, B, C)
P = A * B * C
PROD = P
END FUNCTION

FUNCTION AVERAGE (A, B, C)
AVGR = (A + B + C) / 3
AVERAGE = AVGR
END FUNCTION