midterm2_W2009_key

# midterm2_W2009_key - ELSE IF(score.GE 80 THEN grade ='B...

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

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

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

View Full Document
2.) CHARACTER FUNCTION grade(score) REAL score IF (score .GT. 90.) THEN grade = 'A'
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

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern