Singly Linked List
Singly Linked List
struct Node{
int info;
struct Node *next;
};
tail=list=p;
}
else
list = p;
int deleteFromHead()
{
int ele;
if(NULL == list )
{
printf("\nThere are no element in the Linked List to delete\n");
return NULL;
}
else
{
ele = list>info;
list=list>next;
//return ele;
}
return ele;
}
void insertAtTail()
{
node *p;
int ele;
printf("\n Enter Element to insert At Tail:\n");
scanf("%d",&ele);
p=(node*)malloc(sizeof(node));
p>info = ele;
p>next=NULL;
if(NULL==tail)
tail=list=p;
else
{
tail>next = p;
tail=p;
}
if(NULL == tail )
{
printf("\nThere are no element in the Linked List to delete\n");
return NULL;
}
else
{
for(node *temp=list; temp>next!=NULL; temp=temp>next)
;
ele = tail>info;
free(tail);
tail = temp;
list=list>next;
//return ele;
}
return ele;
}
void displayAll()
{
printf("\n The Element Stored in Linked List Are:\n");
for(node * temp = list ; temp!= NULL; temp= temp>next)
printf("%d\t",temp>info);
}
// getch();
}