Wednesday, October 16, 2019

2. Qbasic program to find the average of any two numbers

Write a program using SUB to find the average of any two numbers given by the user. 



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

No comments:

Post a Comment