From d28ba6eff74413033af661e317562f89ec3fdcc9 Mon Sep 17 00:00:00 2001 From: Devesh Chandra <82612473+devesh1093@users.noreply.github.com> Date: Sun, 24 Oct 2021 01:52:59 +0530 Subject: [PATCH] Create LinkedListImplementation.c --- C/LinkedListImplementation.c | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 C/LinkedListImplementation.c diff --git a/C/LinkedListImplementation.c b/C/LinkedListImplementation.c new file mode 100644 index 00000000..dd24f472 --- /dev/null +++ b/C/LinkedListImplementation.c @@ -0,0 +1,51 @@ +#include +#include +struct node{ + int data; + struct node *next; +}; +typedef struct node NODE; +NODE *head=NULL; +NODE *end=NULL; + +void create( int data){ + NODE *temp; + temp =(NODE*)malloc(sizeof(NODE)); + temp->data=data; + if(head==NULL){ + head=temp; + end=temp; + } + else{ + end->next=temp; + end=temp; + temp->next=NULL; + + } +} +void display(){ + NODE *temp; + temp = head; + while(temp!=NULL){ + printf("%d", temp->data); + printf(" \n"); + temp=temp->next; + } +} + +int main(){ + int n; + printf(" Enter the number of nodes in list:"); + scanf(" %d", &n); + for(int i=0; i