Write a Fortran program that will calculate the sum and average of 9 number.
3 answers
Please know that you will not learn how to do this if someone else does your work for you.
I am not going to my attic to find my boxes full of cards punched with Fortran commands.
I will say how I would go about it though
define an array of numbers of size 9 (you did not say if they were whole numbers)
read the 9 numbers and store them in that array
say i = 0
say sum = 0
add them in a loop from i = 1 to i = 9
sum = sum + number (i)
after i = 9, leave the loop
say av = sum/9
print numbers 1 through 9
print sum = sum
print average = av
end
I will say how I would go about it though
define an array of numbers of size 9 (you did not say if they were whole numbers)
read the 9 numbers and store them in that array
say i = 0
say sum = 0
add them in a loop from i = 1 to i = 9
sum = sum + number (i)
after i = 9, leave the loop
say av = sum/9
print numbers 1 through 9
print sum = sum
print average = av
end
DIM X(9)
SUM=0
DO N=1,9
SUM=SUM+X(I)
CONTINUE
AVG = SUM/9
pretty it up as you will
SUM=0
DO N=1,9
SUM=SUM+X(I)
CONTINUE
AVG = SUM/9
pretty it up as you will