QBASIC – Find sum and average of three numbers

Below is the program to calculate the sum and average of three user input numbers.

' Program to find sum and average of three numbers 
CLS
INPUT "Enter first number"; a
INPUT "Enter second number"; b
INPUT "Enter third number"; c
sum = a + b + c
average = sum / 3
PRINT "The sum of the numbers is ";sum
PRINT "The average of the numbers is ";average
END

Explanation:

To find the sum of three numbers we take the numbers as input from the user and use the addition operator (+). After calculating the sum, the average is calculated by dividing the sum of the numbers by the total count of numbers i.e., 3 for an average of 3 numbers.

Leave a Comment

Your email address will not be published. Required fields are marked *