GateAI
Programming in C

GATE CSE 2012 · Q3

MCQ1 markEasy

Time

What will be the output of the following C program segment?char inChar = 'A' ; switch ( inChar ) { case 'A' : printf ("Choice A\ n") ; case 'B' : case 'C' : printf ("Choice B") ; case 'D' : case 'E' : default : printf ( " No Choice" ) ; }

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: See verified solution

Programming in C

In the given C code snippet:

  1. The variable inChar is initialized to 'A'.

  2. The switch evaluates inChar, matching case 'A'.

  3. The statement printf ("Choice A\ n"); executes, printing Choice A followed by a newline (the space after the backslash \ n is treated as an escaped space or literal in standard formatting, causing a line break).

  4. Since there is no break statement after case 'A', execution falls through to subsequent cases:

    • case 'B' has no statement.

    • case 'C' executes printf ("Choice B");, outputting Choice B.

    • case 'D' and case 'E' fall through to default.

    • default executes printf (" No Choice");, outputting No Choice.

  5. The combined output is: ``` Choice A Choice B No Choice ``` This matches option (C).

*Note*: The official answer key marked this question as Marks to All (Code A) due to a typographical artifact (\ n instead of ` `).

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 Q3 of the GATE CSE 2012 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 2012 has 3.

How GATE tests Programming in C

More from GATE CSE 2012

Share this solution

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

GateAI solution cardGATE CSE 2012 · Q3 · MCQ

What will be the output of the following C program segment? char inChar = 'A' ; switch ( inChar ) { case 'A' : printf ("Choice A n") ; case 'B' : case 'C' : printf ("Choice B") ; case 'D' : case 'E' : default : printf ( " No Choice" ) ; }

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.