C Essentials Part 1 Module 3 Test May 2026
if (sum > 100) printf("HIGH"); else if (sum >= 50 && sum <= 100) printf("MEDIUM"); else printf("LOW"); Run again. 20 40 → LOW . 45 30 → MEDIUM . 80 30 → HIGH . Perfect.
She corrected it:
#include <stdio.h> int main() { int a, b, sum; scanf("%d %d", &a, &b); sum = a + b; if (sum > 100) printf("HIGH"); if (50 <= sum <= 100) printf("MEDIUM"); else printf("LOW"); return 0; } c essentials part 1 module 3 test
She stared. Why both "MEDIUM" and "LOW"?
The terminal glowed green: .
Then she remembered — Module 3’s hidden trap: 50 <= sum <= 100 is parsed as (50 <= sum) <= 100 . (50 <= 60) is 1 , then 1 <= 100 is always true. So the second if always runs, and if the first if fails, the else prints too.
One last question: "Which statement correctly reads a single character and ignores whitespace?" She chose: scanf(" %c", &ch); — the space before %c consumes newline or space. if (sum > 100) printf("HIGH"); else if (sum
She hit . Input: 75 30 → Sum = 105. Output: HIGH . Good. Input: 20 40 → Sum = 60. Output: MEDIUMLOW — Error!