C Program to find the maximum and minimum among n numbers
write(*,*)'Enter the number of variables:'
read(*,*)n
write(*,*)'Enter any one variable:'
read(*,*)x
max=x
min=x
write(*,*)'Enter the other variables:'
do i=2,n
read(*,*)y
if (max.lt.y)max=y
if (min.gt.y)min=y
end do
write(*,*)'The max number is',max
write(*,*)'The min number is',min
end
write(*,*)'Enter the number of variables:'
read(*,*)n
write(*,*)'Enter any one variable:'
read(*,*)x
max=x
min=x
write(*,*)'Enter the other variables:'
do i=2,n
read(*,*)y
if (max.lt.y)max=y
if (min.gt.y)min=y
end do
write(*,*)'The max number is',max
write(*,*)'The min number is',min
end
Comments
Post a Comment