ProgrammingHard
struct R { int v; struct R *next; }; struct R c = {3, NULL}, b = {2, &c}, a = {1, &b}; printf("%d", a.next->next->v); What is printed?
- A. 2
- B. 1
- C. 3
- D. 0
Correct answer: C. 3
a.next is b and b.next is c, so a.next->next->v is c.v, which is 3.
More C Programming questions
- struct Pt { int x, y; }; struct Pt pts[3] = {{1, 2}, {3, 4}, {5, 6}}; struct Pt p = pts + 1; printf("%d %d", p->x, (p - pts)); What is…
- struct Item { int id; int qty; }; struct Item a[2] = {{1, 5}, {2, 7}}; struct Item b = a[1]; b.qty = 0; printf("%d %d", a[1].qty, b.qty)…
- struct Item { int id; int qty; }; struct Item a[3] = {{1, 2}, {3, 4}}; printf("%d", a[2].qty); What is printed?
- struct S { int key; int val; }; struct S arr[4] = {[2] = {7, 70}, {8, 80}}; printf("%d", arr[3].val); What is printed?
- struct S { int key; int val; }; struct S arr[4] = {[2] = {7, 70}, {8, 80}}; printf("%d", arr[1].key); What is printed?
- struct N { char name[8]; int score; }; struct N n = {"Ravi", 90}; printf("%c %d", n.name[1], n.score); What is printed?