1. Given: int a = 2; unsigned int b = -1; When a is compared with b, since unsig
ID: 3591069 • Letter: 1
Question
1. Given: int a = 2; unsigned int b = -1;
When a is compared with b, since unsigned is considered the higher type, C promotes a to an unsigned and does the comparison (a > b) as unsigned. Which best describes the result.
A. The result is false because 2 < unsigned interpretation of -1.
B. The result is true because 2 > -1.
C. The result is true because 2 > 1.
D. Signed positive values are always < an unsigned interpretation of a negative value.
E. A and D above are correct.
2. Given: int a = -7;
unsigned int b = a; What can we say about the bit sequences for a and b?
A. The highest order bit in a will be 1.
B. The highest order bit in b will be 1.
C. Both A and B are correct.
D. Most of the bits in bothaandbwill be 1.
E. ll of the above are correct.
Please briefly explain why, that would be helpful.
Explanation / Answer
1. Ans: E. A and D above are correct.
unsigned interpretation of -1 => 1111 1111 1111 1111 (considering 8 bit length)
clearly 2 < 1
2.
Ans C. Both A and B are correct.
highest order bit in a negative number in always 1 and this only signifies that number is negative.
But in unsigned number if highest order bit is 1 then it is the part of value of number
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.