Match the following:
View worked solution
Answer: A
We can match each C programming construct to its corresponding description as follows:
-
P.
static char var;→ ii. A variable located in data section of memory
Static variables in C have static storage duration. They are allocated in the data segment (specifically, uninitialized static variables are placed in the BSS segment, which is a part of the data section) and persist for the entire lifetime of the program. -
Q.
m = malloc(10); m = NULL;→ iv. A lost memory which cannot be freed
Memory is dynamically allocated on the heap usingmalloc. By reassigning the pointermtoNULLwithout first callingfree(m), the address of the allocated block is lost. This causes a memory leak, as the allocated memory can no longer be accessed or deallocated. -
R.
char *ptr[10];→ i. Sequence of memory locations to store addresses
This defines an array of 10 pointers tochar. Since pointers store memory addresses, this array represents a contiguous sequence of memory locations designed to store addresses. -
S.
register int varl;→ iii. Request to allocate a CPU register to store data
Theregisterstorage class specifier is a hint/request to the compiler to store the variable in a CPU register rather than in RAM, to enable faster access.
Thus, the correct matching is:
P → ii, Q → iv, R → i, S → iii, which corresponds to Option A.
Free practice · Your answers on this page are not saved.
