The GATE Grind

GATE 2017 CS (CS2) – Question 12

Programming and Data Structures · Programming in C · 1 mark · Multiple choice

Match (P) static char var; (Q) m = malloc(10); m = NULL; (R) char *ptr[10]; (S) register int var1; with (i) sequence of memory locations storing addresses, (ii) variable in data section, (iii) request for a CPU register, (iv) lost memory that cannot be freed.

  1. P–ii,Q–iv,R–i,S–iii
  2. P–ii,Q–i,R–iv,S–iii
  3. P–ii,Q–iv,R–iii,S–i
  4. P–iii,Q–iv,R–i,S–ii

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (A) P–ii,Q–iv,R–i,S–iii

Explanation

Static storage belongs to the data area, P–ii. Replacing the only pointer to allocated memory by NULL loses that allocation, Q–iv. An array of ten pointers stores ten addresses, R–i. The register storage-class keyword requests register allocation, S–iii. Thus A; the register request need not be honoured.

More Programming in C questions

All Programming in C questions →