QBasic Programming

Enter any two numbers and display its average

REM PROGRAM TO DISPLAY AVERAGE OF TWO NUMBERS
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
AV = (A + B) / 2
PRINT “AVERAGE OF TWO NUMBERS”; AV
END

USING SUB PROCEDURE
DECLARE SUB AVERAGE (A, B)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
CALL AVERAGE(A, B)
END

SUB AVERAGE (A, B)
AV = (A + B) / 2
PRINT “AVERAGE OF TWO NUMBERS”; AV
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION AVERAGE (A, B)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
AVGR = AVERAGE(A, B)
PRINT “AVERAGE OF TWO NUMBERS”; AVGR
END

FUNCTION AVERAGE (A, B)
AV = (A + B) / 2
AVERAGE = AV
END FUNCTION

Enter any two numbers and display its product (Prev Lesson)
(Next Lesson) Enter any two numbers and display its sum, difference, product and average
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!