In: Computer Science
Explain and demonstrate a Linked List by adding following items into a Linked List: 10, 30, 15, 25 (show your work, you may write on paper and upload if you prefer)


#include<stdio.h>
#include<stdlib.h>
void insert(int n);
void display();
void deletetail();
void deletehead();
void deletepos(int n);
void insertpos(int n);
void inserthead();
struct node
{
        int data;
        struct node *link;
}*head,*tail;
void main()
{
        head=(struct node *)malloc(sizeof(struct node));
        int n;
        tail=head;
        printf("Enter an element: ");
        scanf("%d",&n);
        head->data=n;
        head->link=NULL;
        printf("Want to enter another element: y/n ");
        char c;
        scanf(" %c",&c);;
        while(c!='n')
        {
                printf("Enter element: ");
                scanf("%d",&n);
                insert(n);
                printf("Want to enter another element: y/n ");
                scanf(" %c",&c);
        }
        display();
        printf("\n");
}
void insert(int n)
{
        struct node *temp;
        temp=(struct node *)malloc(sizeof(struct node));
        tail->link=temp;
        temp->data=n;
        temp->link=NULL;
        tail=temp;
}
void display()
{
        struct node *temp;
        temp=head;
        if(!temp)
        {
                printf("No data is available");
                return;
        }
        while(temp)
        {
                printf("%d ",temp->data);
                temp=temp->link;
        }
}