-
Notifications
You must be signed in to change notification settings - Fork 1
/
CLL_IAB.c
77 lines (71 loc) · 1.28 KB
/
CLL_IAB.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct cllist
{
int data;
struct cllist *next;
};
typedef struct cllist node;
node *head=NULL,*ptr;
void CLL_display()
{
node *loc;
loc=head;
if(ptr==NULL)
{
printf("Empty List\n");
getch();
return;
}
else
{
printf("\nCircular Linked list Elements: \n");
do
{
printf("%d\t",loc->data);
loc=loc->next;
}while(loc!=head);
}
getch();
}
void CLL_iab()
{
node *new1;
new1=(node*)malloc(sizeof(node));
printf("Enter data: \n");
scanf("%d",&new1->data);
if (head==NULL)
{
head=new1;
new1->next=head;
ptr=new1;
}
else
{
new1->next=head;
head=new1;
}
ptr->next=head;
}
void main()
{
int ch;
do
{
printf("\nCircular Linked List operations\n");
printf("1.\tInsert at Beginning\n2.\tDisplay\n3.\tExit\n");
printf("Choice: ");
scanf("%d",&ch);
switch(ch)
{
case 1:CLL_iab();break;
case 2:CLL_display();break;
case 3:exit(1);
default: {
printf("Invalid Choice!");
break;
}
}
}while(ch!=3);
}