Skip to content

Instantly share code, notes, and snippets.

@amulyagaur
Created July 16, 2017 18:27
Show Gist options
  • Save amulyagaur/9f22ba4ca4c570ce42f882ad369d333b to your computer and use it in GitHub Desktop.
Save amulyagaur/9f22ba4ca4c570ce42f882ad369d333b to your computer and use it in GitHub Desktop.
node* InsertAtEnd(node* head,int x)
{
node* temp = new node();
temp->data = x;
temp->next=NULL;
node* temp1 = head; // temporary variable to store the head
while(temp1->next!=NULL)
temp1 = temp1->next; //iterating to the end of the list
temp1->next = temp;
return head;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment