Examveda

Which of the following will stop the loop at the last node of a linked list in the following C code snippet?
struct node
{
    struct node *next;
};

A.

while (p != NULL)
{
    p = p->next;
}

B.

while (p->next != NULL)
{
    p = p->next;
}

C.

while (1)
{
    p = p->next;
    if (p == NULL)
        break;
}

D. All of the mentioned

Answer: Option B


This Question Belongs to C Program >> Structure And Union

Join The Discussion

Related Questions on Structure and Union