program aveStDev C********************************************************************** C Compute the average and standarad deviation from a list of unknown size C (no greater than 100). Have the user specify size of list before C they start entering numbers. C********************************************************************** C-----DECLARE VARIABLES real numlist(100), average, stdev real totItems, dummy, aveFunc, stdevFunc parameter(dummy = -9999.0) C-----INITIALIZE LIST data numlist /100*dummy/ totItems = 101 do while (totItems.gt.100) C----------FIND OUT HOW MANY ITEMS TOTAL print *, 'How many numbers will you enter (max is 100)?' read *, totItems end do C-----READ IN DATA call getData(totItems,numlist) C-----COMPUTE AVERAGE OF LIST average = aveFunc(totItems,numlist) print *, 'Average of your list is: ', average C-----COMPUTE STANDARD DEVIATION stdev = stdevFunc(totItems,numlist,average) print *, 'Standard Deviation is: ', stdev stop end C----------------------------------------------------------------------------- subroutine getData(totItems,numlist) real totItems, numlist(totItems) do 100 i = 1, totItems print *, 'Enter number ',i read *, numlist(i) 100 end do return end C----------------------------------------------------------------------------- function aveFunc(cnt,numarray) real cnt, numarray(cnt), total, aveFunc total = 0.0 do 100 i = 1, cnt total = total + numarray(i) 100 end do aveFunc = total / cnt return end C----------------------------------------------------------------------------- function stdevFunc(cnt,numarray,ave) real cnt, numarray(cnt), ave, stdevFunc, sumsqrs sumsqrs = 0.0 do 100 i = 1, cnt sumsqrs = sumsqrs + (numarray(i) - ave)**2.0 100 end do stdevFunc = sqrt(sumsqrs / (cnt-1)) return end