Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions Linked_List/Insertion_of_node_at_tail_of_LinkedList.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

#include <iostream>

using namespace std;



struct Node
{
int data;
struct Node *next;
};

struct Node *head;

void
Insert (int data)
{
struct Node *temp = (struct Node *) malloc (sizeof (struct Node *));


temp->data = data;
temp->next = NULL;

if (head == NULL)
{
head = temp;
return;
}

struct Node *temp2 = head;
while (temp2->next != NULL)
{
temp2 = temp2->next;
}
temp2->next = temp;
}

void
Print ()
{
struct Node *temp = head;
while (temp != NULL)
{
printf (" %d", temp->data);
temp = temp->next;
}
printf ("\n");

}


int
main ()
{
head = NULL;
Insert (4);
Insert (6);
Insert (8);
Insert (2);
Print ();

return 0;
}