Toronto Metropolitan University
Exam Sample Questions - Spring 2025
Below are sample questions along with explanations for each one. You can download the original file at the bottom of the page to try them out yourself! If you have any questions, please feel free to reach out or write a post in the community!
Q 1) Convert 32 into signed integer binary.
a) 1000 0000 0000 0000 0000 0000 0101 1001
b) 0000 0000 0000 0000 0000 0000 0010 0000
c) 0000 0000 0000 0000 0000 0000 0001 0000
d) 1000 0000 0000 0000 0000 0000 0010 0000
e) none of the above
Answer: b)
Explanation:
In binary, decimal 32 is
100000(that’s 2^5) in just 6 bits.But as a 32‐bit signed integer, we need 32 bits total. Leading zeros fill up the extra space, giving
0000 0000 0000 0000 0000 0000 0010 0000.32 bits are required for a full signed int, so leading zeros are added to fill out the remaining bits.
Q 2) Convert 0000 0000 0000 0000 0000 0000 1100 0111 into integer decimal.
a) 123
b) 194
c) 199
d) 227
e) none of the above
Answer: c) 199
Explanation:
Focus on the lower 8 bits:
1100 0111.Converting
1100 0111to decimal:(1 × 2^7) + (1 × 2^6) + (0 × 2^5) + (0 × 2^4) + (0 × 2^3) + (1 × 2^2) + (1 × 2^1) + (1 × 2^0)
= 128 + 64 + 0 + 0 + 0 + 4 + 2 + 1 = 199.
Q 3) Convert
1100 0001 0100 0000 0000 0000 0000 0000into floating‐point decimal.a) 35.0
b) -200.0
c) -12.0
d) -24.0
e) none of the aboveAnswer: c) -12.0
Explanation:
First bit = 1 → negative number
Exponent bits =
10000010→ decimal 130 → actual exponent is 130 - 127 = 3Mantissa starts with an implied
1.0, followed by zeros → actual value is1.5So the number is:
-1.5 × 2³ = -12.0
That matches option (c).
Q 4) Convert hexadecimal 2A into integer decimal.
a) 21
b) 35
c) 42
d) 68
e) none of the aboveAnswer: c) 42
Explanation:
Hex 2A means (2 × 16) + (10) = 32 + 10 = 42.
Q 5) Which expression is invalid (all variables are integers)?
a)
a + b - 0
b)c % a % 4
c)xm6 - 24
d)xf3r6 + 2
e) all are validAnswer: e) all are valid
Explanation:
While
xm6andxf3r6look unusual, in C you can name integer variables like that as long as they are declared properly (e.g.,int xm6;).The modulo chain in (b) is also valid if
c % ayields some int, then% 4again.Subtraction by 0 or adding an integer is also valid.
Q 6) Which expression is invalid?
a)
ant + int
b)one + twx
c)three * 3
d)four / -4
e) all are valid
Keep reading this lesson
You've reached the end of the free preview. Unlock the rest of this lesson in Toronto Metropolitan University.
- Unlimited coding questions
- Unlimited access to all classroom material
- Weekly live call for questions and guidance
- 3,000 AI tutor tokens / month
- Personal SQL database (3 MB)
- Progress tracking
Cancel any time.