Question 9944 – Programming
February 13, 2024Question 9824 – Programming
February 13, 2024Question 9820 – Programming
The most appropriate matching for the following pairs
X: m=malloc(5); m= NULL; 1: using dangling pointers Y: free(n); n->value=5; 2: using uninitialized pointers Z: char *p; *p = ’a’; 3. lost memory
is:
Correct Answer: D
Question 24 Explanation:
X → m = NULL will results the loss of memory.
Y → n is pointer to invalid memory, a making it as a dangling pointer.
Z → p is not initialized.
p = malloc (size of(char))p = malloc (size of(char)); should have been used before assigning ‘aa’ to ∗p.
Y → n is pointer to invalid memory, a making it as a dangling pointer.
Z → p is not initialized.
p = malloc (size of(char))p = malloc (size of(char)); should have been used before assigning ‘aa’ to ∗p.
X – 1 Y – 3 Z – 2
X – 2 Y – 1 Z – 3
X – 3 Y – 2 Z – 1
X – 3 Y – 1 Z – 2
Subscribe
Login
0 Comments