GateAI
Programming in C

GATE CSE 2017 Set 2 · Q2

MCQ1 markEasy

Time

Match the following:

GATE CSE 2017 Set 2 Q2 diagram

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) P → (ii), Q → (iv), R → (i), S → (iii)

Programming in C

Let us analyze each item:

  • (P) static char var;: Static variables are allocated memory in the data section (specifically the BSS/initialized data segment) of memory. Thus, P →\rightarrow (ii).

  • (Q) m = malloc(10); m = NULL;: Memory allocated dynamically using malloc is orphaned when the pointer m is set to NULL without calling free(m). This causes a memory leak, which is lost memory that cannot be freed. Thus, Q →\rightarrow (iv).

  • **(R) char *ptr[10];: This declares an array of 10 pointers to char, which is a contiguous sequence of memory locations used to store addresses. Thus, R →\rightarrow (i)**.

  • (S) register int var1;: The register storage class is a hint/request to the compiler to store the variable in a CPU register for faster access. Thus, S →\rightarrow (iii).

Matching combination: P →\rightarrow (ii), Q →\rightarrow (iv), R →\rightarrow (i), S →\rightarrow (iii), which corresponds to option A.

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 Q2 of the GATE CSE 2017 Set 2 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 2017 Set 2 has 6.

How GATE tests Programming in C

More from GATE CSE 2017 Set 2

Share this solution

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

GateAI solution cardGATE CSE 2017 Set 2 · Q2 · MCQ

Match the following:

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.