midterm2_W2009_key

midterm2_W2009_key - ELSE IF (score .GE. 80.) THEN grade =...

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

View Full Document Right Arrow Icon
Midterm 2 W09 Key: SHORT ANSWERS - Octal number 777 = binary number 111111111 - Hexadecimal number FFF = decimal number 4095 - Barcelona, Spain - -9. - Speed History - Charles Babbage - First programmer - Transistor; low cost, small in size UNIX 1. Rediret output of a.out to file cat 2. Append output of a.out to file cat PROBLEM 1 1.) 15. 456. 7. 8. 7. 8. 456. 7. 123. 2.) -2. 8. -2. 81. 3.) n=5 f= 0 n=4 f= 0 n=3 f= 0 n=2 f= 0 n=1 f= 0 result= 0 4.) 220.00 76.00 95.00 114.00 133.00 5.) 1 5 1.50 5.00 PROBLEM 2 1.) DO i = 1, 100 PRINT*, 7*i ENDDO
Background image of page 1

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

View Full DocumentRight Arrow Icon
2.) CHARACTER FUNCTION grade(score) REAL score IF (score .GT. 90.) THEN grade = 'A'
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ELSE IF (score .GE. 80.) THEN grade = 'B' ELSE grade = 'F' ENDIF RETURN END 3.) LOGICAL FUNCTION odd(x) INTEGER x odd = MOD(x,2) .NE. 0 RETURN END PROBLEM 3 REAL FUNCTION xSQRT(A,G) REAL A,G, Gnew diff = 1. DO WHILE (abs(diff) .GT. 0.00001) Gnew = ((A/G)+G)/2. diff = Gnew-G G = Gnew ENDDO xSQRT = Gnew RETURN END PROBLEM 4 PROGRAM root EXTERNAL f REAL a, b, c, f PRINT*, 'Enter values for a and b' READ*, a, b c = (a+b)/2. DO WHILE (abs(f(c)) .GT. 0.001) IF (f(a)*f(c) .LT. 0) THEN b = c ELSE a = c ENDIF c = (a+b)/2. ENDDO PRINT*, 'x = ', c END...
View Full Document

Page1 / 2

midterm2_W2009_key - ELSE IF (score .GE. 80.) THEN grade =...

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

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