FOR2(2) - CGS-2421 FORTRAN EXAM II, TEST FORM CODE...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
CGS-2421 FORTRAN EXAM II, TEST FORM CODE "A", SPECIAL CODE "02", SPRING 2009 This exam is OPEN BOOK, OPEN NOTES, CLOSED NEIGHBOR. Cheaters will receive a ZERO on the exam. Be SURE to read all instructions. You will not receive any partial credit if the instructions are not correctly followed. All variables are of their default type unless otherwise specified. Read each question carefully before answering the question. Instructions for filling out your answer sheet: - Read the information on the back of the answer sheet. - Code the test form code letter (on the title line of this page) in the TEST FORM CODE field. You lose 5 points if you do not code this field. - Code the special code number (on the title line of this page) in the SPECIAL CODES field. - Write and code your name in the LAST NAME, FI, MI fields. - Write and code your UFID. THIS FIELD IS IMPORTANT! You lose 5 points if you do not code this field. - Code the answers to the questions below. The 10 multiple choice questions in this exam are worth 5 points each (50). Question 11-13 are worth a total of 50 points. In the CGS2421 grade system, you will get a separate grade for each part. The sum of the two grades will be your grade for this exam.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1. Consider the following subroutine SUBROUTINE SUB(F,K,SIZE,N) INTEGER :: F,N,SIZE,I INTEGER :: K(SIZE) DO I=1,SIZE IF(K(I) > N) THEN WRITE(UNIT=F,FMT=*) K(I) ENDIF ENDDO END SUBROUTINE What does this subroutine do? A. It copies the first n elements of array K to the file. B. It copies the elements of array K that are greater than N to the file. C. It writes to the file int numbers 0. ..size. D. It reads from the file size integers and copies them into array K. E. It reads from the file size integers and copies those that are greater than N to array K. 2. Consider the following declaration in the main program CHARACTER(10) :: S(5) INTEGER :: N and the function header INTEGER FUNCTION FOO(S) CHARACTER :: S ... Which of the following is the correct call from the main? A. N=FOO(S) B. FOO(S(3)) C. FOO(S(3)(4:4) D. N=FOO(S(3)(4:4)) E. CALL FOO(S(3))
Background image of page 2
3. Consider the following program segment INTEGER :: L CHARACTER(5) :: MASCOT(2) CHARACTER(20) :: S MASCOT(1)='GATOR' MASCOT(2)='PACK' S=MASCOT(1)//' FOOTBALL' L=INDEX(S,'BALL') S(L:L)=' ' WRITE(*,'(A)') S(1:LEN_TRIM(S)) What is the output? A. GATOR B. GATOR FOOT ALL C. GATORFOOTBALL D. GATOR FOOT E. GATOR BALL 4. Consider the following statements CHARACTER(20) :: D D = 'IBm2000' CALL SUB(D) WRITE(*,*) D and the subroutine SUBROUTINE SUB(S) CHARACTER(*) :: S INTEGER :: I DO I = 1, LEN(S) IF(S(I:I) >= 'A' .AND. S(I:I) <= 'Z') THEN S(I:I)=CHAR(ICHAR(S(I:I))-1) ENDIF ENDDO END SUBROUTINE What is the output? A. HAM2999 B. HAl2000 C. HAL2000 D. HAm2000 E. HAL1///
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
5. Consider the following Fortran program INTEGER :: I, J INTEGER :: K(2,3) = RESHAPE((/0,2,3,5,6,8/),(/2,3/)) DO I=1,2 WRITE(*,*) (K(I,J), J=2,1,-1) ENDDO END PROGRAM A. 0 3 2 5 B. 3 0 5 2 C. 3 6 5 8 D. 0 6 2 8 E. 3 6 8 2 6. Consider the following statements
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

FOR2(2) - CGS-2421 FORTRAN EXAM II, TEST FORM CODE...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online