Match the following: \(\begin{array}{|ll|ll|}\hline P. & \text{static char var…
2017
Match the following:
\(\begin{array}{|ll|ll|}\hline P. & \text{static char var ;} & \text{i.} & \text{Sequence of memory locations to store addresses} \\\hline Q. & \text{m = malloc(10); m =NULL ;} & \text{ii.} & \text{A variable located in data section of memory} \\\hline R. & \text{char *ptr[10] ;} & \text{iii.} & \text{Request to allocate a CPU register to store data} \\\hline S. & \text{ register int varl;} & \text{iv.} & \text{A lost memory which cannot be freed} \\\hline\end{array}\)
- A.
P-ii; Q-iv; R-i; S-iii
- B.
P-ii; Q-i; R-iv; S-iii
- C.
P-ii; Q-iv; R-iii; S-i
- D.
P-iii; Q-iv; R-i; S-ii
Attempted by 321 students.
Show answer & explanation
Correct answer: A
Answer: P → ii; Q → iv; R → i; S → iii
P: "static char var;" — A static variable has static storage duration and is placed in the data section of memory.
Q: "m = malloc(10); m = NULL;" — Allocating memory and then overwriting the pointer with NULL loses the only reference to the allocated block, creating a memory leak (lost memory that cannot be freed).
R: "char *ptr[10];" — This declares an array of 10 pointers to char, i.e., a sequence of memory locations to store addresses.
S: "register int varl;" — The register storage-class specifier requests that the compiler store the variable in a CPU register (note: the compiler may ignore the request).
Key idea: match each declaration to its storage or behavior: static → data section, malloc then losing pointer → memory leak, array of pointers → sequence of addresses, register → request for CPU register.
A video solution is available for this question — log in and enroll to watch it.