1If x contains the integer decimal value 42 which of the fol
1.If x contains the integer decimal value 42, which of the following are TRUE statements? Select ALL correct responses.
The binary (base 2) representation of x is 101010.
The hexadecimal representation of x is 2A (written in C as 0x2A).
The value of the expression (x ^ x) is 1.
The decimal value of the expression (x >> 1) is 21.
The binary value of the expression (x << 2) is 10101000.
2. In our C environment, which ONE of the following best describes how a double is represented internally?
One sign bit, 8 exponent bits, and 23 mantissa bits, for a total of 32 bits.
An integer value represented in two\'s-complement format.
One sign bit, 11 exponent bits, and 52 mantissa bits, for a total of 64 bits.
An integer value represented in one\'s-complement format.
An integer value, where the leftmost bit is the sign, and the remaining 31 bits represent the magnitude.
3. Assuming we have a large collection of very small double values and very large double values, and we need write a program to compute the sum of all of these values, which ONE of the following statements is FALSE?
No matter what order we add the numbers in (e.g., smallest to largest, largest to smallest, random order, etc.), we will always end up with the exact same sum.
Adding the largest numbers first and then adding in the smallest numbers can give us a different result from adding the smallest numbers first and then adding in the largest.
Because we have a fixed number of significant digits, our computations can be affected by round-off error.
4. Which ONE of the following mathematics expressions correctly describes the number of unique binary values we can represent using a sequence of N bits?
2(N-1)
2N
2N-1
N2
2·N
N
5. Which of the following are TRUE statements about the parts of a C compiler? Select ALL correct responses.
The preprocessor runs first, pulling in #include files, substituting #define symbols, and stripping out comments.
The code generator needs to have deep knowledge of the machine instructions available on the CPU hardware for which the program is being compiled.
The parser knows the rules of C, and issues error messages when we break those rules.
The lexical analyzer runs as the very last step of the compilation process.
The preprocessor #define macros can be dangerous because of operator precedence rules and expression side-effects.
Solution
1) Yes the binary conversion of 42 is 101010
42/2 = 21 remainder 0
21/2 = 10 remainder 1
10/2 = 5 remainder 0
5/2 = 2 remainder 1
2/2 = 1 remainder 0
x in binary is 101010
and Hexadecimal representation of x is 2A
101010 - make it 8 bits long and divide in group of four
0010 1010
0010 - 2
1010 - A
Hence hexadecimal representation of x is 2A

