program nested_do
implicit none
REAL,DIMENSION(50,50)::my_array
INTEGER::m,n,i,j,e
PRINT *, '============================================'
PRINT *, 'PROGRAM TO UNDERSTAND NESTED DO [ BY - BOTTOMSCIENCE.COM ]'
PRINT *, '============================================'s
print *, 'Please enter the value of rows and columns respectively'
read(*,*)m,n
e=m*n
print *, 'Enter the',e,'elements'
loop_outer: do i=1,m
loop_inner: do j=1,n
read(*,*) my_array(i,j)
end do loop_inner
end do loop_outer
do i=1,m
write(*,*) (my_array(i,j),j=1,n)
end do
end program
OUTPUT
============================================
PROGRAM TO UNDERSTAND NESTED DO [ BY – BOTTOMSCIENCE.COM ]============================================
Please enter the value of rows and columns respectively
2
3
Enter the 6 elements
1
2
3
4
5
6
1.00000000 2.00000000 3.00000000
4.00000000 5.00000000 6.00000000