Asked by MOHAMMED
Write a Fortran program that will calculate the sum and average of 9 number.
Answers
Answered by
DrBob222
Please know that you will not learn how to do this if someone else does your work for you.
Answered by
Anonymous
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
Answered by
oobleck
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
There are no AI answers yet. The ability to request AI answers is coming soon!