#include<stdio.h>
#include<malloc.h>
struct node
{
    int info;
    struct node *next;
    };
    struct node *start;

int main()
{
    int n;
    char cont;

    do
    {
        system("cls");
        printf("Enter 1 to insert from last\nEnter 2 to insert from start\nEnter 3 to delete from last\nEnter 4 to delete from start\nEnter 5 to insert at a position\nEnter 6 to delete from a position\nEnter 7 to display\n");
    scanf("%d",&n);
    switch(n)
    {
        case 1:
        { insertlast();
        break;
        }
        case 2:
        {
            insertstart();
            break;
            }
        case 3:
        {
            deletelast();
            break;
            }
        case 4:
        {
            deletestart();
            break;
            }
      /*  case 5:
        {
            insertpos();
            break;
            }
        case 6:
        {
            deletepos();
            }*/
        case 7:
        {
            display();
        }
        }
     printf("\n\n\ndo you want to continue\n");
     scanf(" %c",&cont);}
     while(cont=='y');
     return 0;
     }

    //'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    // insert last........................................................................................
    int insertlast()
    {
        struct node *nn,*temp;
        //int n;
        nn=((struct node*)malloc(sizeof(struct node)));
        printf("\n\nenter no.\n\n\n");
        scanf("%d",&nn->info);

        nn->next=NULL;
        if(start==NULL)
        {
           start=nn;

        }
        else
        {
            temp=start;
            while(temp->next!=NULL)
            {
                temp=temp->next;
            }
            temp->next=nn;
        }
        return 0;
        }






    //''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''//
    int insertstart()
    {
        int n;
        struct node *nn,*temp;
        printf("\n\nenter no.\n\n");
        scanf("%d",&n);
        nn=((struct node*)malloc(sizeof(struct node)));
        nn->info=n;


            temp=start;
            start=nn;
            start->next=temp;

        return 0;
    }

    /*int insertstart()
{
struct node *nn;
nn = ((struct node*)malloc(sizeof(struct node)));
printf("\n\nEnter the value\t");
scanf("%d",&nn->info);
nn->next=start;
start=nn;
return 0;
}*/
    int deletelast()
    {
        struct node *temp,*temp1;
        temp=start;
        while(temp->next->next!=NULL)
        {
            temp=temp->next;

        }
        temp1=temp->next;
        temp->next=NULL;
        free(temp1);

return 0;
    }

    int deletestart()
    {
        struct node *temp;
        temp=start;
        start=start->next;
        free(temp);
        return 0;
    }
    int display()
    {
        struct node *temp;
        temp=start;
        while(temp!=NULL)
        {
            printf("%d \n",temp->info);
            temp=temp->next;
        }
       return 0;// printf("%d",temp->info);
    }
