' AVERAGE.BAS
' This program prints the average of three numbers.

DECLARE FUNCTION Average! (int1%, int2%, int3%)   ' declare function

CLS

PRINT "Enter three integers to be averaged together."
PRINT
INPUT "    First integer:  ", first%
INPUT "    Second integer:  ", second%
INPUT "    Third integer:  ", third%

PRINT
PRINT "The average is"; Average!(first%, second%, third%)

END

FUNCTION Average! (int1%, int2%, int3%)

sum% = int1% + int2% + int3%    ' sum of arguments

Average! = sum% / 3             ' return value is average of arguments

END FUNCTION

