original-1,2,3,4,5,6,7
1st iteration-2,1,3,4,5,6,7
2nd iteration- 2,1,4,3,5,6,7
3rd iteration- 2,1,4,3,6,5,7
after this step p pointing to 7 and q pointing to NULL.
at last ternary operator execute - q = p->next (as p hold address of 7) i.e q= NULL
while loop terminate as q=NULL
so answer is B