Can the insertion at Tail be Like this

void insertattail(node* &head, int data, int pos)

{

    node* temp = head;

	while(temp->next != NULL){
		temp = temp ->next;
             }
	node* n = new node(data);

	temp->next = n;
	n->next = NULL;

}

@JaveedYara

  1. you dont need “pos” for insertAtTail
  2. You can omit this line n->next = NULL; because n->next is already pointing at NULL.

Rest is all correct.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like