Passing arguments by passing a link to a swap function

I ran into this problem while solving a practice test

Consider the following cross-reference language code, such as FORTRAN and these code statements

  subroutine swap(ix,iy)
    it = ix
    ix = iy    ! line L1
    iy = it    ! line L2
  end

  program main
    ia = 3
    ib = 8
    call swap (ia, ib+5)
    print *, ia, ib
  end program

Statements:

  • The compiler will generate code to highlight a temporary nameless cell, initialize it to 13 and pass the address of the exchange cell
  • When the code is executed, a runtime error will be generated on line L1
  • When the code is executed, a runtime error will be generated on the L2 line
  • The program will print 13 and 8
  • The program will print 13 and -2

Which of the above statements (statements) is / correct.

I think S1 and S4. Can anyone confirm this? TIA

0
2

, S1 S4 .

,

S0a: , , L1: L2: .:)

S0b: , FORTRAN , :

+3

@janneb... Fortran 95:

module my_subs

contains

subroutine swap(ix,iy)

integer :: ix, iy
integer :: it

it = ix
ix = iy
iy = it

end subroutine swap

end module my_subs

program test_swap

use my_subs

integer :: ia, ib

ia = 3
ib = 8

call swap (ia, ib+5)

print *, ia, ib

end program test_swap

, . gfortran lax "S4", 13 8.

:

integer, intent (inout) :: ix, iy

gfortran :

: ( INTENT = OUT/INOUT) (1)

Intel ifort:

test_swap.f90 (31): # 6638: ; , INTENT (OUT) INTENT (INOUT). call swap (ia, ib + 5) ----------------- ^ test_swap.f90 ( 1)

, Fortran . , , FORTRAN 77 .

+2

All Articles