From 1c6680651cdfa0c8a52425b2db32abf4153af631 Mon Sep 17 00:00:00 2001 From: gautam20863 <56150963+gautam20863@users.noreply.github.com> Date: Thu, 24 Oct 2019 00:23:06 +0530 Subject: [PATCH] Create Another c program --- Another c program | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Another c program diff --git a/Another c program b/Another c program new file mode 100644 index 0000000..de6f3a4 --- /dev/null +++ b/Another c program @@ -0,0 +1,68 @@ +#include +#include +#include +struct node{ + int data; + struct node *link; +}; +struct node *head=NULL; +struct node *temp,*prev=NULL,*newnode; + +void ins_beg(int ele){ + newnode = (struct node*)malloc(sizeof(int)); + newnode->data=ele; + newnode->link=head; + if(head == NULL) + { + temp=newnode; + } + else + { + temp->link=newnode; + } + head=newnode; + +} + + +void del_end() +{ + temp =head->link; + while(temp != head) + { + prev=temp; + temp=temp->link; + } + prev->link=head; +} + +void display() +{ + printf("%d \n",head->data); + temp =head->link; + while(temp!=head) + { + printf("%d \n",temp->data); + temp=temp->link; + } +} + +void main() +{ + printf("program begins here\n"); + ins_beg(1); + ins_beg(2); + ins_beg(3); + ins_beg(4); + ins_beg(5); + printf("linked list:\n"); + display(); + del_end(); + printf("deleted linked list:\n"); + display(); + del_end(); + printf("deleted linked list:\n"); + display(); + getch(); + +}