Complete the function Add to add a new Node to a FIFO queue
Solution
Here is the code for you:
Node *p = malloc(sizeof(Node));
Add(p);
Add(Node *p)
{
int temp;
printf(\"Enter the value to insert: \");
scanf(\"%d\", &temp);
p->info = temp;
p->next = NULL;
if(pTail == NULL) //If there are no nodes in the Queue
pTail = pHead = p; //Add this single node itself, and make the head and tail point to this node.
else //If there are some nodes in the queue.
{
p->next = pTail; //Add this as the last element in the queue, and make the last element come after this p.
pTail = p; //Make pTail point to this node p.
}
}
If you need any refinements, just get back to me.
