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
 Spring '11
 Staff
 Computer Programming, the00

Click to edit the document details