Skip to content
GATEiit

GATE CSE 2017 Session 2 Q12: Match C declarations with their memory meaning

Syllabus topic: Programming in C

Question

Match the following:

Column IColumn II
(P) static char var;(i) Sequence of memory locations to store addresses
(Q) m = malloc(10); m = NULL;(ii) A variable located in data section of memory
(R) char *ptr[10];(iii) Request to allocate a CPU register to store data
(S) register int var1;(iv) A lost memory which cannot be freed

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 1/3 mark in GATE.
Show answer and explanation

Answer: A (official GATE 2017 final answer key)

Concept used: C storage classes and pointers: static variables live in the data section, overwriting the only pointer to heap memory leaks it, an array of pointers stores addresses, and register requests a CPU register.

Concept notes

Loading notes…

First step: For each declaration ask where the object lives or what happens to memory, starting with the malloc followed by NULL assignment.

Full step-by-step solution

Loading…

Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.

More questions on Programming in C

Every PYQ on this topic →

Share this question

WhatsAppDownload image

Source: official GATE 2017 Session 2 CS question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key