C array.f

C Program array:

	program array

C Variable declaration:

	integer n
	real a(10), sum, max, min

C length of array:

	n = 10

C fill array with values:

	data a / -1,4,2,6,-2,3,9,7,8,5 /

C compute results:

	sum = mysum(a,n)
	max = mymax(a,n)
	min = mymin(a,n)
	
	write (*,*) 'sum = ', sum
	write (*,*) 'max = ', max
	write (*,*) 'min = ', min
	end


C function mysum:

	function mysum(list,n)
	integer n
	real list(n), sum
	sum = 0.0
	do i = 1, n
         	sum = sum + list(i)
	end do 
	mysum = sum
	return
	end

C function mymax:

	function mymax(list,n) 
	integer n
	real list(n), max
	max = list(1)
	if(n.gt.1)then
		do i = 2, n 
			if(list(i).gt.max)then	
				max = list(i)
			end if
		end do 
	end if
	mymax = max
	end 

C function mymin:

	function mymin(list,n) 
	integer n
	real list(n), min
	min = list(1)
	if(n.gt.1)then
		do i = 2, n
			if(list(i).lt.min)then	
				min = list(i)
			end if
		end do 
	end if
	mymin = min
	end 

