Consider the following C program.
void f(int, short);
void main()
{
int i = 100;
short s = 12;
short *p = &s;
__________ ; // call to f()
}Which one of the following expressions, when placed in the blank above, will NOT result in a type checking error?
GATE CS - 2016,
Answer: D
The call that type-checks is f(i,*p).
f is declared as taking an int and a short and returning void. \(i\) is an int, and p is a pointer to short, so *p is a short: the arguments match exactly.
The other choices fail. f(s,*s) and f(i,*s) dereference s, which is a short, not a pointer, so *s is a type error. i = f(i,s) has valid arguments but assigns the result of a void function to an int, which is also a type error.
Please log in or register to report this question.



