#include<stdio.h>
#include<stdlib.h>
struct node 
{
    int info;
	struct node *link;
};
struct node *addtobeg(struct node *start,int data)
{
	struct node *tmp;
	tmp=(struct node *)malloc(sizeof(struct node));
	tmp->info=data;
	tmp->link=NULL;
	start=tmp;
	return start;
}
struct node *addtoend(struct node *start,int data)
{
	struct node *tmp,*p;
	if(start==NULL)
	{
		printf("No 1st element:\n");
		return start;
	}
	p=start;
	while(p->link!=NULL)
	p=p->link;
	tmp=(struct node *)malloc(sizeof(struct node));
	tmp->info=data;
	tmp->link=p->link;
	p->link=tmp;
	return start;
}
void display(struct node *start)
{
	struct node *p;
	if(start==NULL)
	{
		printf("Empty list:\n");
		return;
	}
	p=start;
	printf("\n");
	while(p!=NULL)
	{
	  printf(" %d",p->info);
	  p=p->link;
    }
    printf("\n");
}
struct node *create_list(struct node *start)
{
	start=addtobeg(start,23);
	start=addtoend(start,67);
	start=addtoend(start,89);
	start=addtoend(start,7);
	start=addtoend(start,34);
	return start;
}
struct node *deletes(struct node *start)
{
	struct node *current,*next;
	current=start;
	while(current!=NULL)
	{
		next=current->link;
		free(current);
		start=next;
		current=next;
	}
	start=NULL;
	return start;
}
int main()
{
	struct node *start;
	start=NULL;
	start=create_list(start);
	display(start);
	printf("After deletion:\n");
	start=deletes(start);
	display(start);
	return 0;
}