From 9a5896b4047603cf05233c63a88f276d5030c1ac Mon Sep 17 00:00:00 2001 From: deveshpareek01 <72197240+deveshpareek01@users.noreply.github.com> Date: Fri, 2 Oct 2020 14:57:13 +0530 Subject: [PATCH] Create circular.c this is a c program plz check this out . this is a dsa alogrithums circular link;list program. --- circular.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 circular.c diff --git a/circular.c b/circular.c new file mode 100644 index 0000000..205c59c --- /dev/null +++ b/circular.c @@ -0,0 +1,51 @@ +#include +#include +#include +struct node{ + int info; + struct node* link; +}*new_node,*start,*temp,*last; +void create() +{ + int value; + int choice; +do +{ + new_node = (struct node*)malloc(sizeof(struct node)); + printf("enter value"); + scanf("%d",&value); + new_node->info=value; + new_node->link=NULL; + if(start==NULL) + { + start=new_node; + last=new_node; + } + else + { + last->link=new_node; + last=new_node; + last->link=start; + } + printf("press 1 to continue 0 to exit"); + scanf("%d",&choice); +} +while(choice==1); +} +void display() +{ + printf("linklist : "); + temp=start; + while(temp->link!=start) + { + printf("%d->",temp->info); + temp=temp->link; + } + printf("%d",temp->info); +} +int main() +{ +create(); +display(); +return 0; +}