Hi, I am a very new FreeBasic programmer and experiencing an issue which is probably easily fixable... I am making an average and sum calculator, and having trouble making the running total & max number inputted to work. The answers keep coming up as 0.
dim scores(20) as integer
dim i as integer
dim sumscore(20) as integer
dim sumruntotal as integer
dim sumtotal as integer
dim sum as integer
dim average as integer
dim runningtotal as integer
dim max as integer
i = 1
runningtotal = 0
max = 0
do
print "Enter a score"
input scores(i)
i = i + 1
runningtotal = runningtotal + scores(i)
print "The running total is", runningtotal
if scores(i) > max then max = scores(i)
print "The max score is", max
loop until i > 5
i = 1
print "Your scores are:"
do
print scores (i);
i = i + 1
print
loop until i > 5
i = 1
sumtotal = 0
do
sumscore(i) = scores(i)
sumruntotal = sumscore(i)
sumtotal = sumtotal + sumruntotal
i = i + 1
loop until i > 5
print "The sum of the scores are"; sumtotal; "."
print "The average of the scores are"; sumtotal /5
sleep
dim scores(20) as integer
dim i as integer
dim sumscore(20) as integer
dim sumruntotal as integer
dim sumtotal as integer
dim sum as integer
dim average as integer
dim runningtotal as integer
dim max as integer
i = 1
runningtotal = 0
max = 0
do
print "Enter a score"
input scores(i)
''i = i + 1 moved to just before loop end
runningtotal = runningtotal + scores(i)
print "The running total is", runningtotal
if scores(i) > max then max = scores(i)
print "The max score is", max
i = i + 1
loop until i > 5
i = 1
print "Your scores are:"
do
print scores (i);
i = i + 1
print
loop until i > 5
i = 1
sumtotal = 0
do
sumscore(i) = scores(i)
sumruntotal = sumscore(i)
sumtotal = sumtotal + sumruntotal
i = i + 1
loop until i > 5
print "The sum of the scores are"; sumtotal; "."
print "The average of the scores are"; sumtotal /5
Hello, thanks for helping me out. I actually managed to figure it out in class a couple of days ago and made it a bit better. Here it is if you want to look at it.
dim scores(30) as integer
dim i as integer
dim sumscore(30) as integer
dim sumruntotal as integer
dim sumtotal as integer
dim sum as integer
dim average as integer
dim runningtotal as integer
dim max as integer
dim min as integer
i = 1
runningtotal = 0
do
print "Enter a score"
input scores(i)
if i = 1 then max = scores(i)
if i = 1 then min = scores(i)
if min > scores(i) then min = scores(i)
print "The min score is", min
if scores (i) > max then max = scores(i)
print "The max score is", max
runningtotal = runningtotal + scores(i)
print "The running total is", runningtotal
i = i + 1
loop until i > 5
i = 1
print "Your scores are:"
do
print scores (i);
i = i + 1
print
loop until i > 5
i = 1
sumtotal = 0
do
sumscore(i) = scores(i)
sumruntotal = sumscore(i)
sumtotal = sumtotal + sumruntotal
i = i + 1
loop until i > 5
print "The sum of the scores are"; sumtotal; "."
print "The average of the scores are"; sumtotal /5
print "The maximum number inputted was"; max
print "The minimum number inputted was"; min
sleep