program matrix integer [100][100] :: matrix1, matrix2, resultMatrix integer :: m1Rows, m1Columns, m2Rows, m2Columns, temp, temp2 subroutine sumMatrices do temp = 1, m1Rows then do temp2 = 1, m1Columns then resultMatrix(temp,temp2) = matrix(temp,temp2) + matrix(temp,temp2) resultMatrix(1,1) = 2 end do end do end subroutine subroutine printResultMatrix do temp = 1, m1Rows then do temp2 = 1, m1Columns then print resultMatrix(temp,temp2) , ' ' end do print '\n' end do end subroutine subroutine readMatrix1 do temp = 1, m1Rows then do temp2 = 1, m1Columns then print 'Enter value (', temp, ',', temp2, ') For matrix1\n' read matrix1(temp,temp2) end do end do end subroutine subroutine readMatrix2 do temp = 1, m1Rows then do temp2 = 1, m1Columns then print 'Enter value (', temp, ',', temp2, ') For matrix2\n' read matrix2(temp,temp2) end do end do end subroutine subroutine readM1Dimensions print 'Enter the rows of the first matrix' read m1Rows print 'Enter the columns for the first matrix' read m1Columns end subroutine subroutine readM2Dimensions print 'Enter the rows of the second matrix' read m2Rows print 'Enter the columns for the second matrix' read m2Columns end subroutine do then readM1Dimensions() readM2Dimensions() if (m1Rows == m2Rows) then exit end if end do readMatrix1() readMatrix2() sumMatrices() printResultMatrix() end program