These are review questions for midterm number two.
Q1
Do the following conversions, showing exactly how they
are done. Show all your work below and on the back of the
previous page, as needed. The small number in parentheses after
the number indicates the base of the number. All numbers and bit
patterns are 16 bits wide.
Note: 16^{2} = 256, 16^{3} = 4,096, 16^{4}
= 2^{16} = 65,536, 2^{10} = 1,024
0000 0001 0010 0100_{(2)}  signed binary, to decimal 
292 
1111 1110 1101 1100_{(2)}  signed binary, to decimal 
292 
1000 0001 0010 0100_{(2)}  unsigned binary, to decimal 
33,060 
1000 0001 0010 0100_{(2)}  signed binary, to hexadecimal 
8124_{(16)} 
1111 1110 1101 1100_{(2)}  unsigned binary, to octal 
177334_{(8)} 
Q2
Do the following conversions, showing exactly how they
are done. Show all your work below and on the back of the
previous page, as needed. The small number in parentheses after
the number indicates the base of the number. All numbers and bit
patterns are 16 bits wide.
Note: 16^{2} = 256, 16^{3} = 4096, 16^{4}
= 2^{16} = 65536, 2^{10} = 1024
10A9_{(16)}  signed hexadecimal, to decimal  4,265 
EF57_{(16)}  signed hexadecimal, to decimal  4,265 
A0A9_{(16)}  unsigned hexadecimal, to decimal  41,129 
293_{(10)}  decimal, to binary  0000 0001 0010 0101_{(2)} 
293_{(10)}  decimal, to binary  1111 1110 1101 1011_{(2)} 
Q3
Print T in the box if the statement is True; print F if it is False. Correct answers are worth 1 mark each. No answer is worth zero marks. Incorrect answers are worth minus 1 mark (1) each.
There are eight bytes in a bit of computer memory.  F 
Each computer memory address has ten bytes.  F 
CPU stands for Control Program Unit.  F 
The CPU operates on numbers read from computer memory.  T 
The binary decimal 0.1_{(2)} means "1 times 2 to the power 1"  T 
Signed numbers have more positive numbers than negative ones.  F 
If you subtract ASCII ‘A’ from ASCII ‘C’, you get the value two.  T 
The largest unsigned 8bit integer has the value 256_{(10)}.  F 
The largest signed 16bit integer has the value 32,767_{(10)}.  T 
Minus one (1) has the value FF_{(16)} for 8bit and 16bit numbers.  F 
Adding one to the most negative signed number gives the most positive signed number.  F 
Bit number 16 is always the sign bit of all signed numbers.  F 
Signed numbers all have the sign bit set to one.  F 
To negate a bit pattern, subtract it from minus one (1).  F 
ASCII characters and numbers look the same when stored as bits in computer memory.  T 
FFFF_{(16)} and 177777_{(8)} have the same numeric value.  T 
18_{(8)} is an octal number with decimal value 16_{(10)}.  F 
This is a valid pseudocode assignment statement: x + y ß 7  F 
In a signed integer, if you invert the bit pattern for zero, you get the bit pattern for minus one.  T 
Signed numbers are always negative.  F 
C preprocessor directives start with a ‘%’ as the first nonblank character.  F 
<stdio.h> contains definitions of printf and scanf  T 
Constant macros must be all lowercase (small) letters  F 
Declarations must always precede executable statements  T 
Reserved words have special meanings and cannot be used for other purposes  T 
Identifiers may start with letters or digits  F 
PI is a standard identifier defined in <stdio.h>  F 
2 + 5 = sum; is a C language assignment statement that puts 7 into "sum"  F 
printf("%f%f%f",2.3); outputs the value 2.3 on the screen three times  F 
printf("Hello\nThere\n"); prints "Hello There " on the screen with blanks  F 
(* this is a C language comment *)  F 
The magnitude of m % n is always less than n  T 
m % n can never be zero  F 
Dividing 100 by 0 causes overflow and all the bits are turned on  F 
If x is 2, then printf("%d", 3x); prints the number 6 on the screen  F 
Q4
Pick appropriate numeric representations, either Integer or Float, for the various quantities and measurements given below, and justify your answers on the given lines.
Assume that integers are 16bit signed values, and floatingpoint numbers have the standard Clanguage float properties. Enter in the box the word Integer or Float for the storage type that is most appropriate to store the given measurements, and explain why.
The number of pencils in your desk at home.  
Your body temperature, in Celsius, to 3 significant digits.  
The exact price of ten boxes of Macaroni and Cheese Dinner.  
The speed of a car in kilometres per hour. 
Integer/Float? Explain your choice here…








Q5
Give the answers to the following questions in decimal
numbers.
For partial marks in answering these questions, show below how
you arrived at the answer.
What is the largest unsigned value that can be stored in 12 bits?  4,095 = 2^{12}1  
What is the smallest signed value that can be stored in 12 bits?  2,048 = 2^{11}  
What is the largest signed value that can be stored in 12 bits?  2,047 = +2^{11}1 
Q6
What is the value of the following C language expression?  25 % 18 / 2 + 4 =  7 
Q7
Show how the floatingpoint number 99.682 would appear when printed using each of the following output formats. Show leading and/or trailing blanks in the output of formatted numbers using a capital ‘X’ character in place of the blanks that would normally appear, e.g. XXX98.6XX
%8.4f  99.6820 
%8.3f  X99.682 
%8.2f  XX99.68 
%8.1f  XXX99.7 
%8.0f  XXXX100 
%.1f  99.7 
Q8
Do the following conversions. The small number in parentheses
after the number indicates the base of the number. All numbers
and bit patterns are 16 bits wide.
Note: 16^{2} = 256, 16^{3} = 4,096, 16^{4}
= 2^{16} = 65,536, 2^{10} = 1,024
345_{(10)}  decimal to hexadecimal  
0000 0111 1000 0011_{(2)}  signed binary to decimal  
77_{(10)}  decimal to binary  
FFA5_{(16)}  signed hexadecimal to decimal  
AAA4_{(16)}  unsigned hexadecimal to decimal 
Q9
Write complete C language declarations for the variables used in the scanf function call below:
scanf( "%x %u %d %f", &One, &Two, &Three, &Four );
One:  
Two:  
Three:  
Four: 