homework and midterm

There are 0 64s in 42 there are 1 32s in 42 there are

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: = 6 k= 6 m= 7 n= -6 . 18. Given the following code fragment, write the value of the variables after the fragment executes: i = int b=2; int i=0; for(i=0; i<2; i++){ b+=i; } b -= i; 2 b = 1 . 2 19. Convert the unsigned decimal number 42 to an 8 ­bit binary number: 27=128 26=64 25=32 24=16 23=8 22=4 21=2 20=1 there are 0 128’s in 42. there are 0 64’s in 42. there are 1 32’s in 42. there are 0 16’s in 10. there are 1 8’s in 10. there are 0 4’s in 2. there are 1 2’s in 2. there are 0 1’s in 2. 42 remaining 42 remaining 42 ­32 = 10 remaining 10 remaining 10 ­8= 2 remaining 2 remaining 2 ­2=0. 0 remaining start copying from the first 0 at the top, you have 00101010. (42)10 = (00101010)2 20. Convert the following 8 ­bit binary number to an unsigned decimal number (N.B: Most significant bit is on the left): 00001111 27=128 26=64 25=32 24=16 23=8 22=4 21=2 20=...
View Full Document

This note was uploaded on 10/16/2011 for the course CSC 210 taught by Professor Staff during the Spring '11 term at S.F. State.

Ask a homework question - tutors are online