Difficulty: Medium
Correct Answer: 4, 12
Explanation:
Introduction / Context:
This question checks understanding of typedef names versus identifiers and how a local variable can shadow a typedef name, affecting sizeof and evaluation of expressions in Turbo C.
Given Data / Assumptions:
float i;
introduces a variable named i of type float, shadowing the typedef name i.
Concept / Approach:
sizeof(i) refers to the variable i (type float), not the typedef. The arithmetic abs uses ints: a = 2, b = 3, s = 2, so the product is 12.
Step-by-Step Solution:
1) Shadowing: within fun, float i;
means i is a variable, so sizeof(i) = sizeof(float) = 4.2) Compute abs = 232 = 12.3) Output format prints "4, 12".
Verification / Alternative check:
Rename the variable (e.g., float f;
) and observe sizeof now prints 2 if you use sizeof(i) where i is the typedef int.
Why Other Options Are Wrong:
Options A/B/C assume incorrect sizes or miscompute the product.
Common Pitfalls:
Confusing typedef names with variables; sizeof applied to an identifier uses the identifier's current binding in scope.
Final Answer:
4, 12
Discussion & Comments