I need to help my friend. It is simple task. I need to find a smallest element in the array.
program TEST
! your code goes here
integer a(5), n, min
a = (/2, -5, 3, 5, 8/)
n = 5
min = a(1)
!reading from keyboard
!do i=1,n
!read*,a(i)
!end do
print*, 'array:'
do i=1,n
print*,a(i)
end do
!print*, 'отладка, поиск минимального:'
do i=2,n
if (min .lt. a(i)) then
min = a(i)
!print*, min, a(i), ' '
end if
end do
print*, 'minimal: '
print*, min
stop
end
So. I don't have problem with alghoritm at all. It is easy for me to do it on any other language)) but not there. Problem appears when I compare min and a(i).
Programm thinks that min < a(i) all time. Why? So min would be 8, because 8 is the last.