Insert Node from End in Linked List

Google Advertisements

Prev Tutorial Next Tutorial

Insert Node from Back in Linked List in C++

Insert data from back is very similar to the insert from front in the linked list. Here the extra job is to find the last node of the linked list.

insert new node from back in linked list in c++


node *temp1;                         // create a temporary node
temp1=(node*)malloc(sizeof(node));   // allocate space for node
temp1 = head;                  // transfer the address of 'head' to 'temp1'
while(temp1->next!=NULL) // go to the last node
      temp1 = temp1->next;//tranfer the address of 'temp1->next' to 'temp1'

Now, Create a temporary node node *temp and allocate space for it. Then place info to temp->data, so the first field of the node node *temp is filled. node *temp will be the last node of the linked list. For this reason,temp->next will be NULL. To create a connection between linked list and the new node, the last node of the existing linked list node *temp1`s second field temp1->next is pointed to node *temp.


node *temp;                           // create a temporary node
temp = (node*)malloc(sizeof(node));  // allocate space for node
temp->data = info;                   // store data(first field)
temp->next = NULL;                   // second field will be null(last node)
temp1->next = temp;                  // 'temp' node will be the last node

Prev Tutorial Next Tutorial

Google Advertisements

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements

Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: or 8076671483 Try this Keyword C++ Programs