Difficulty: Easy
Correct Answer: The program will print the output 10 20.
Explanation:
Introduction / Context:
This checks understanding of default arguments captured at compile time, name shadowing between a file-scope static and a local variable, and what happens when the caller supplies both parameters explicitly anyway.
Given Data / Assumptions:
static int b = 0
initializes the default for y
as &b
.main
declares a local b = 20
which shadows the global name in that scope.&a
and &b
(the local one).
Concept / Approach:
Because the call provides y
, the default is not used. Therefore, dereferencing *x
yields 10 and *y
yields 20 from the local b
. The existence of the global static only matters if the second argument were omitted.
Step-by-Step Solution:
Verification / Alternative check:
If you called DisplayData(&a)
with no second argument, the output would be "10 0" due to the default binding to the file-scope static b
.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing which b
is referenced when both a global and local exist; explicit argument selection wins here.
Final Answer:
The program will print the output 10 20.
Discussion & Comments