ProgrammingHard

struct Node { int v; struct Node *next; }; struct Node *head = NULL; for (int i = 1; i <= 3; i++) { struct Node *n = malloc(sizeof *n); n->v = i * i; n->next = head; head = n; } printf("%d", head->next->v); What is printed?

  1. A. 4
  2. B. 9
  3. C. 1
  4. D. 0

Correct answer: A. 4

Head insertion puts 9 first, then 4 and then 1. The second node holds 4.

More C Programming questions

Exams that ask this topic