Consider the following C program. b = c * d; e = c + 1; if (e < 10) { t1 = 2 *…
2025
Consider the following C program.
b = c * d;
e = c + 1;
if (e < 10)
{
t1 = 2 * d;
}
else
{
t1 = e / 2;
}
- A.
Constant folding
- B.
Constant propagation
- C.
Dead code elimination
- D.
None of the above
Attempted by 27 students.
Show answer & explanation
Correct answer: C
This code snippet performs arithmetic operations and conditional assignment. Without subsequent usage of variables b, e, or t1, a compiler may apply Dead Code Elimination to remove these computations entirely. Constant propagation is not possible here due to unknown variable values.