From 9e1f5ad4d9ce51fc17214a8e378688e21a88ae65 Mon Sep 17 00:00:00 2001 From: akash-ranjan8 Date: Fri, 11 Oct 2019 01:53:30 +0530 Subject: [PATCH] modified the Fundamentals --- .../Fundamental/circulardoublelink.c | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Data Structures/Fundamental/circulardoublelink.c diff --git a/Data Structures/Fundamental/circulardoublelink.c b/Data Structures/Fundamental/circulardoublelink.c new file mode 100644 index 0000000..eee918f --- /dev/null +++ b/Data Structures/Fundamental/circulardoublelink.c @@ -0,0 +1,48 @@ +#include +#include +struct node +{ int data; + struct node *next; + struct node *prev; +}; +struct node *head=NULL; +void create(int d) +{ struct node *new,*t; + new=(struct node*)malloc(sizeof(struct node)); + new->data=d; + new->next=NULL; + new->prev=NULL; + if(head==NULL) + { head=new; + new->next=head; + head->prev=new; + new->prev=head; + } + else + { t=head; + do + { t=t->next; + }while(t!=head->next); + t->next=new; + new->prev=t; + t=new; + new->next=head; + head->prev=new; + + } +} +void display() +{ struct node *ptr; + ptr=head; + do + { printf("%d",ptr->data); + ptr=ptr->next; + }while(ptr!=head); + +} +void main() +{ create(1); + create(2); + create(5); + display(); +}