midterm-1b-solutions

midterm-1b-solutions - CSE 110 Midterm Exam 1 Form B Fall...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSE 110 Midterm Exam 1 Form B Fall 2010 ANSWER KEY NAME (please print legibly): Your University ID Number: NO BS bonus: If you do not know the answer to a problem and leave it blank you will receive 1 point for each part (e.g., a,b,c, etc.) that you leave blank. If you write anything in the space and it is wrong, you will receive a 0. You will not lose any points for small coding details or occasional misspellings. QUESTION VALUE SCORE 1 6 2 6 3 14 4 6 5 12 6 6 7 6 8 6 9 6 10 6 11 8 12 6 13 6 14 6 15 10 TOTAL 110 1 1. (6 points) What output is produced by the following code fragment? NOTE: indentation may be misleading! int limit = 100; int num1 = 20; int num2 = 20; if (limit <= limit) { if (num1 == num2) System.out.print("lemon "); System.out.print("lime "); } System.out.println("grape"); (a) lemon lime grape (b) grape (c) lime grape (d) lemon lime ANSWER: A 2. (6 points) The hexadecimal value 92 represents a twos complement binary value. Translate this value into base 10. You must show your work in order to receive any credit for this problem. 92 = 1001 0010 = 10010010 = -128 + 16 + 2 = -110 (Assign 3 points if the student translates the value as unsigned binary instead, getting 146 or -146 as an answer) 2 3. (14 points) Translate 100.5 into 32-bit floating point representation and convert the result into hexadec- imal notation. Remember that 32-bit representation has 1 sign bit, an 8-bit exponent (with a bias of 127), and a 23-bit mantissa field. You must show your work in order to receive partial (or any) credit....
View Full Document

This note was uploaded on 09/14/2011 for the course CSE 110 taught by Professor Shaunakpawagi during the Spring '08 term at SUNY Stony Brook.

Page1 / 8

midterm-1b-solutions - CSE 110 Midterm Exam 1 Form B Fall...

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

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