If we want to find last node of a singly linked list then the correct coding is
To reach the last node, we have to keep moving forward as long as the current node has a next node. That needs a loop, not a single if:
while (temp->link != NULL)
temp = temp->link;When the loop stops, temp->link is NULL, so temp points to the last node.
Option (A) uses if, so it moves only one step. Options (B) and (D) check the data field, which is unrelated.
Answer: (C)
Reinforce your conceptual grasp with related questions from CUET-MCA 2024:
Take timed full-length mock tests with authentic question distributions, negative marking (+12/-3 in Math), and instant All India Rank calculation.
Start Free Mock Test Series →