Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions c/LinkedList.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include<stdio.h>
#include<stdlib.h>
struct node
{
    int x;
    struct node *next;
}*start;
void in_end(int x)
{
    struct node *temp,*q;
    temp=(struct node*)malloc(sizeof(struct node));
    temp->x=x;
    temp->next=NULL;
    if(start==NULL)
    start=temp;
    else
    {
        q=start;
        while(q->next!=NULL)
        q=q->next;
        q->next=temp;
    }
}
void del_allnode()
{
    struct node *p;
    if(start==NULL)
        printf("List is empty.");
    else
    {   p=start;
        for(;p!=NULL;)
        {
            start=start->next;
            p->next=NULL;
            free(p);
            p=start;
        }
    }
}
void main()
{
    int n,x,k;
    start=NULL;
    struct node *p;
    printf("enter the number of element\n");
    scanf("%d",&n);
    printf("enter the numbers\n");
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);
        in_end(x);
    }
    del_allnode();
}