Average of Many Numbers

Purpose : QBasic TAFE Assessment

Programs : QBasic

Scripts: QBasic


A slightly more complex version of the Average of 3 Numbers. This script allows a user to input multiple numbers and it will calculate and display the average of the numbers given.

The Code:

[cc lang=”vb”]
‘*****************************
‘ Made by Ian Blott 16/2/2005

‘*****************************

‘Clear the screan
CLS

‘Prompt the user to enter their chosen numbers
PRINT “Please enter the numbers you would like to get the average of:”

b = 0

INPUT a
IF INKEY$ <> “*” THEN
INPUT a
END IF

b = b + a
DO UNTIL a = 0
INPUT a
b = b + a
y = y + 1
LOOP

z = b / (y – 1)

‘This will display the result / average of the numbers.
PRINT “the average is “; z; “”

[/cc]