Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. 8. Match the following :
    (P) Static char var;    (i) Sequence of memory locations to store addresses
    (Q) m = malloc (10);    (ii) A variable located in data m = NULL; section of memory
    (R) char * ptr [10];    (iii) Request to allocate a CPU register to store data
    (S) register int var 1;    (iv) A lost memory which 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)
Correct Option: A

1. Static char var; : Initialization of a variable located in data section of memory because var is defined as character variable whose associated storage class is static.
2. m = m alloc (10); m = Null; A lost memory which cannot be freed because free (m) is missed in code due to 10 contiguous bytes of memory is allocated is address of first byte is stored in ‘m’ and later it is updated with NULL. Now we lost the address of first bytes of that chunk of memory completely, so we can’t free that space as we need the address of first byte to free it.
3. Char * Ptr [10]; : Sequence of memory locations to store addresses because ptr is an array of 10 pointers pointing to character variables.
4. Register int var1; : Request to allocate a CPU register to store data because the complier to store the var 1 “value” in CPU Register. Hence, option (d) is correct.



Your comments will be displayed only after manual approval.