Difficulty: Easy
Correct Answer: 1, 4, 4
Explanation:
Introduction / Context:
This problem checks your knowledge of the sizeof operator in C, particularly how it treats variables, character constants, and floating constants under a typical 32-bit data model where char=1 byte, int=4 bytes, and float=4 bytes.
Given Data / Assumptions:
Concept / Approach:
sizeof(variable) yields the storage size of that object’s type. In C, a character constant like 'A' has type int (not char), so sizeof('A') equals sizeof(int). A float constant with suffix f has type float.
Step-by-Step Solution:
sizeof(ch) = 1 (because ch is char).sizeof('A') = sizeof(int) = 4 (character constants are of type int).sizeof(3.14f) = sizeof(float) = 4.Printed result: 1, 4, 4.
Verification / Alternative check:
Replace the character constant with a variable: int x = 'A'; sizeof(x) also returns 4 on this model, reinforcing the rule.
Why Other Options Are Wrong:
(a) assumes sizeof('A') is 2, which is nonstandard here. (c) and (d) mismatch the stated data model. (e) incorrectly treats a character constant as a char.
Common Pitfalls:
Believing sizeof('A') equals 1 because it “looks like a char”; forgetting the f suffix forces a float (not double).
Final Answer:
1, 4, 4
Discussion & Comments