Skip to content
Related Articles

Related Articles

Improve Article

GATE | GATE-CS-2016 (Set 1) | Question 22

  • Last Updated : 12 Aug, 2021

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?

(A) f(s, *s)

(B) i = f(i,s)
(C) f(i,*s)
(D) f(i,*p)


Answer: (D)

Explanation: i is integer and *p is value of a pointer to short.

1) Option 1 is wrong because we are passing “*S” as second argument check that S is not a pointer variable .So error
2) Second option is we are trying to store the value of f(i,s) into i but look at the function definition outside main it has no return type. It is simply void so that assignment is wrong. So error
3) Option 3 is wrong because of the same reason why option 1 is wrong
4) So option d is correct.





Quiz of this Question

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up
Recommended Articles
Page :