C Program to find the sum and average using array
dimension a(100)
sum=0.0
write(*,*)'Enter the no. of data you want to enter:'
read(*,*) n
write(*,*)'Now, enter the data:'
do i=1,n
read(*,*)a(i)
sum=sum+a(i)
end do
ave=sum/real(n)
write(*,*)'The sum of the given numbers is',sum
write(*,*)'The average of the given numbers is',ave
end
dimension a(100)
sum=0.0
write(*,*)'Enter the no. of data you want to enter:'
read(*,*) n
write(*,*)'Now, enter the data:'
do i=1,n
read(*,*)a(i)
sum=sum+a(i)
end do
ave=sum/real(n)
write(*,*)'The sum of the given numbers is',sum
write(*,*)'The average of the given numbers is',ave
end
Comments
Post a Comment