|
News
Lab Schedule
QuickBasic Notes
Fortran Notes
Tutor Room
Winplot Manual
Lab Home
xxxxxxxxxxxxxxxxxx
| |
program listdemo
c This program computes the mean, maximum, minimum, and
c range of a list of numbers. The list is input by the user.
real list(100), mean, max, min, range
integer n
print *, "How many numbers are on your list ?"
print *, "No more than 100, please."
read *, n
do i = 1, n
print *, "Enter your next number :"
read *, list(i)
end do
call data(n,list,mean,max,min)
print *
print *, "The mean is", mean
print *, "The maximum is", max
print *, "The minimum is", min
print *, "The range is", max - min
print *, "Bye"
end
subroutine data(n,list,mean,max,min)
real list(100), mean, max, min, sum
integer n
sum = 0
max = list(1)
min = list(1)
do i = 1, n
sum = sum + list(i)
if (list(i) .gt. max) max = list(i)
if (list(i) .lt. min) min = list(i)
end do
mean = sum/n
end
|