Multiple choice technology programming languages

struct aaa{ struct aaa *prev; int i; struct aaa *next; }; main(){ struct aaa abc,def,ghi,jkl; int x=100; abc.i=0;abc.prev=&jkl; abc.next=&def; def.i=1; def.prev=&abc; def.next=&ghi; ghi.i=2; ghi.prev=&def; ghi.next=&jkl; jkl.i=3; jkl.prev=&ghi; jkl.next=&abc; x=abc.next->next->prev->next->i; printf("%d",x); }

  1. 1

  2. 2

  3. 3

  4. nullpointer assignment

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Tracing the pointers: abc.next points to def, def.next points to ghi, ghi.prev points back to def, def.next points to ghi, and ghi.i equals 2. The entire expression evaluates to 2. Option A (1) would be def.i, and Option C (3) would be jkl.i.