You should have received 7 pages, including this title page. You will have 45 minutes to complete this exam. The exam is graded out of 100 points, with each problem marked as to how many points it is worth (the number in the box). You may use a a crib sheet, as described in the syllabus, throughout the entire test. However, you may not use a computer or calculator to help solve the problems. You are highly encouraged to show your work and explain how you arrived at your answer, so that we can give as much partial credit as possible for any incorrect answers. Be sure you write your name on each page. must also sign the following declaration: I understand that collaboration of any form is not permitted on this nal exam. All work I present here is my own, and I agree not to divulge the contents of this exam until answers have been published. You
Signature:
Page 1 of 7
Octal 0 1 2 3 4 5 6 7
0 0 0 0 1 1 1 1
Bits 0 0 1 1 0 0 1 1
0 1 0 1 0 1 0 1
Decimal 0 1 2 3 4 5 6 7 1 0 6 6
0 0x
1 1 0 1 0 1 3 2 d
Figure 1: Binary, octal, hexadecimal conversions %i integer (any base) %d integer (decimal) %o integer (octal) %x, %X integer (hexadecimal) %f, %e, %g oat %s string Figure 2: I/O formats
Page 2 of 7
Page 3 of 7
(b) After this code executes, what will be printed? int a = 0 x20 , b = 02; a >> b ; printf ( " a =% d , b =% d \ n " , a , b );
(c) After this code executes, what will be printed? int i = 0 , sum =0; while ( i <= 5) { sum += i ; printf ( " sum [% d ] = % d \ n " , i , sum ); i ++; }
Page 4 of 7
Page 5 of 7
Page 6 of 7
30
Page 7 of 7