GateAI
Programming in C

GATE CSE 2016 Set 1 · Q12

MCQ1 markEasy

Time

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?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: D) f(i, *p)

Programming in C

Let us analyze the function signature and variables:

  • Function prototype: void f(int, short); which expects two arguments of type int (or promotable) and short, and returns void.

  • Variable types: i is of type int, s is of type short, and p is of type short *.

Evaluating each option:

  • **(A) f(s, *s)**: s is a variable of type short (not a pointer), so applying the indirection operator *s causes a compilation/type error (dereferencing a non-pointer).

  • (B) i = f(i, s): Function f has a return type of void. Assigning the result of a void function to an int variable results in a type-checking error.

  • **(C) f(i, *s)**: Dereferencing s via *s is invalid because s is not a pointer type.

  • **(D) f(i, *p)**: i is an int, and *p dereferences the pointer short *p to yield a value of type short. This matches the parameter types (int, short) expected by f, and the void return value is simply ignored as a statement expression.

Therefore, option D is correct.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Programming in C previous year question is Q12 of the GATE CSE 2016 Set 1 paper. Find more GATE CSE PYQs on Programming in C in Programming and Data Structures, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Programming in C PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Programming in C in GATE CSE

Programming in C has 74 GATE CSE PYQs across 25 papers from 2011 to 2026. 20 of them are 1-mark MCQs like this one, and GATE CSE 2016 Set 1 has 3.

How GATE tests Programming in C

More from GATE CSE 2016 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2016 Set 1 · Q12 · MCQ

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?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.