#include<stdio.h>
#include<stdlib.h>
struct node
{
    int data;
    struct node* next;
};
struct node * root=NULL;
void display();
void  deleteAtend();
void insert();
int main()
{
    int ch;
    while(1)
    {
        printf("1.delete an element at the End of link list\n");
         printf("2.add element in link list\n");
        printf("3.display element\n");
        printf("4.exit\n");
        printf("Enter your choice\n");
        scanf("%d",&ch);
           switch(ch)
           {
           case 1:
           deleteAtend();
            break;
          case 2:
            insert();
                break;
          case 3:
            display();
            break;
          case 4:
            exit(1);
            break;
          default:
            printf("Invalid choice\n");
           }
    }
}
 void deleteAtend()
{
    int count=0,i;
    struct node *p,*t;
    p=root;
    if(root==NULL)
        printf("NO element present in the list so you cant delete element\n");
    else
    {
        while(p->next!=NULL)
        {
            t=p;
            p=p->next;

        }
         free(t->next);
         t->next=NULL;
    }

}
void display()
{
  struct node * temp;
  temp=root;
  if(temp==NULL)
        printf("List is Empty\n");
  else
  {
      while(temp!=NULL)
      {
          printf("%d-->",temp->data);
          temp=temp->next;
      }
      printf("NULL\n");
  }
}
void insert()
{
    struct node* temp;
temp=(struct node*)malloc(sizeof(struct node));
printf("Enter node data to add begin\n");
scanf("%d",&temp->data);
temp->next=NULL;
if(root==NULL)
    root=temp;
else
{
    temp->next=root;
    root=temp;
}
}