Question.3
A developer checks if a sensor reading is below a threshold:
int error_code = -1; unsigned int threshold = 1; if (error_code < threshold) { printf("Below threshold"); } else { printf("Above threshold"); }
What is the output?
Select Answer
Below threshold — -1 is less than 1
Above threshold — -1 is promoted to a huge unsigned value (4,294,967,295), which is greater than 1
Compilation error — cannot compare signed and unsigned
Below threshold — the compiler converts threshold to signed for comparison