CSCE 150 Final Exam Dec. 12, 00
Name:____________________________ SSN: __________
Instructions: Do all of the
following questions and show your work.
then after the reversing process, you should have: A(1)=8, A(2)=3, A(3)=7.
0 0 1
0 2 0
3 0 0
If N=4, then your matrix should be
0 0 0 1
0 0 2 0
0 3 0 0
4 0 0 0
And so on. Note: your program should be general and should work for any value of N.
(a) Define CPU and RAM.
(b) List two major components of CPU.
PROGRAM MyProgram
IMPLICIT nonE
INTEGER :: K, M
K=5
M=MyFunc(K)
M=M+1
INCLUDES
FUNCTION MyFunc(K)
INTEGER, INTENT(IN) :: K
IF (MOD(K,3)==0) MyFunc=0
IF (MOD(K,3)>1)
MyFunc=K-2
ELSE
MyFunc==K-1
END IF
END MyFunc
PRINT *, “Value is: “, M
END PROGRAM MyprograM
6. (15 points) Implement a RECURSIVE Fortran 90 FUNCTION whose only input is a positive integer N and whose only output is the number of digits contained in N.
PROGRAM Final_Program
IMPLICIT NONE
INTEGER :: N, J, K, R
INTEGER, DIMENSION(:,:), ALLOCATABLE :: A
N=3
ALLOCATE(A(3,3))
DO J=1, N
DO K=1, N
A(J,K)=4
END DO
END DO
DO J=1, N
DO K=1, J
A(J,K)=-9
END DO
END DO
DO J=1, N
PRINT *, (A(J,K), K=1, N)
END DO
PRINT *
PRINT *
R=K**2
R=R/2
DO K=1, N
A(K,K)=R+K
END DO
PRINT *, ((A(J,K), K=1, 2), J=1, 2)
DEALLOCATE(A)
END PROGRAM Final_Program