Question & Answer: Student No: (a) [5 Points] Write a subroutine that receives two 1-D arrays A and B are int…..

Student No: (a) [5 Points] Write a subroutine that receives two 1-D arrays A and B are integer numbers of size n that are passed from the main program and returns a third 1-D array C of size n. Each element in C shows whether an element from A can be divided by the corresponding element in B. See the example below. You are requested to write the subroutine only while the main program will be in the next section. 10 2

solve this fortran problem

Student No: (a) [5 Points] Write a subroutine that receives two 1-D arrays A and B are integer numbers of size n that are passed from the main program and returns a third 1-D array C of size n. Each element in C shows whether an element from A can be divided by the corresponding element in B. See the example below. You are requested to write the subroutine only while the main program will be in the next section. 10 2

Expert Answer

 

subroutine array(A,B)
implicit none     
   ! dummy arguments      
   int, intent (in) :: A     
   int, intent (in) :: B      
   real, intent (in) :: temp    
   character, intent (out) :: C   
   
   !Get size of 1d array
   asize=size(A)
   bsize=size(B)
   
   !Run loop over one dimensional array
   do i=1,size(A)
      !Check B(i) divides A(i) if yes C(i)=T else C(i)=F
      temp=mod(A(i),B(i))
      IF (temp==0) THEN
        C(i)='T'

ELSE

C(i)=’F’

END IF

end subroutine array
Still stressed from student homework?
Get quality assistance from academic writers!