Multiple choice general knowledge science & technology

struct vg { int cry; int cop; int count; struct vg *next; }; void append(struct vg **q,int cry, int cop) { struct vg *temp,*r; temp = *q; if(*q==NULL) { temp = (struct vg *)malloc(sizeof(struct vg)); temp->cry=cry; temp->cop=cop; temp->count = 0; temp->next=NULL; *q=temp; } else { temp = *q; while(temp->next !=NULL) { temp=temp->next; } r = (struct vg *)malloc(sizeof(struct vg)); r->cry=cry; r->cop = cop; r->count = 0; r->next=NULL; temp->next=r; } } void main() { int cry=0,cop=0; struct vg *p; p=NULL; printf(" Enter the Crystal and coupler number"); scanf("%d %d",&cry, &cop); How the append function should be called.

  1. append(*p,cry,cop);

  2. append(&p,cry,cop);

  3. append(**p,cry,cop);

  4. append(p,cry,cop);

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

The append function takes a double pointer (struct vg **q) to modify the head pointer. When calling from main with p (a single pointer), we must pass &p to match the double pointer parameter. Option B does this correctly.