QBASIC Program to get any two numbers from the user and print the average.
CLS
INPUT "Enter First Number: "; a
INPUT "Enter Second Number: "; b
av=(a+b)/2
PRINT "Average = "; av
END
INPUT "Enter First Number: "; a
INPUT "Enter Second Number: "; b
av=(a+b)/2
PRINT "Average = "; av
END
Using SUB Procedure
DECLARE SUB avrg(a,b)
INPUT "Enter First Number: "; a
INPUT "Enter Second Number: "; b
CALL avrg(a,b)
SUB avrg(a,b)
av=(a+b)/2
PRINT "Average = "; av
END SUB
INPUT "Enter First Number: "; a
INPUT "Enter Second Number: "; b
CALL avrg(a,b)
END
SUB avrg(a,b)
av=(a+b)/2
PRINT "Average = "; av
END SUB
Using FUNCTION Procedure
DECLARE FUNCTION avrg(a,b)
CLS
INPUT "Enter First Number: "; a
INPUT "Enter Second Number: "; b
av = avrg(a,b)
PRINT "Average = "; av
END
CLS
INPUT "Enter First Number: "; a
INPUT "Enter Second Number: "; b
av = avrg(a,b)
PRINT "Average = "; av
END
FUNCTION avrg(a,b)
av = (a+b)/2
sum = av
END FUNCTION
No comments:
Post a Comment
If you have any doubts, Please let me know.