StreakPeaked· Practice

ExamsGATETechnical

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?

  1. f(s,*s)
  2. i = f(i,s)
  3. f(i,*s)
  4. f(i,*p)

Correct answer: f(i,*p)

Solution

The expression 'f(i,*p)' correctly passes an integer and a short to the function 'f', as 'i' is an integer and '*p' dereferences to the short value stored in 's', thus matching the function's parameter types without causing a type checking error.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →