freebasic-examples/src/repeats.fb.bas

24 lines
492 B
QBasic

Dim As Single total, count, number
Dim As String text
Print "This program will calculate the sum and average for a"
Print "list of numbers. Enter an empty value to see the results."
Print
Do
Input "Enter a number: ", text
If text = "" Then Exit Do
count += 1
total += Val(text)
Loop
Print
Print "You entered: "; count; " number(s)"
Print "The sum is: "; total
If count > 0 Then Print "The average is: "; total / count
Print
Print "Any keypress ends program.";
Sleep