-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path29.Queue_linklist.c
More file actions
71 lines (67 loc) · 1.97 KB
/
29.Queue_linklist.c
File metadata and controls
71 lines (67 loc) · 1.97 KB
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
/* Name:Shylesh S
Roll No: 47
Program No. 29
Program: Queue Using Array */
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node *link;
};
void main()
{
struct node *head,*temp,*tem;
int cho,ele;
head=(struct node*)malloc(sizeof(struct node));
head->data=NULL;
head->link=NULL;
do
{
printf("\nMENU\n1.Insertion\n2.Deletion\n3.Display\nEnter choice: ");
scanf("%d",&cho);
switch(cho)
{
case 1: printf("Enter element: ");
scanf("%d",&ele);
tem=head;
while(tem->link!=NULL)
{
tem=tem->link;
}
temp=(struct node*)malloc(sizeof(struct node));
temp->link=NULL;
tem->link=temp;
temp->data=ele;
break;
case 2: if(head->link==NULL)
{
printf("\nQueue is EMPTY\n");
}
else
{
tem=head->link;
temp=tem->link;
head->link=temp;
printf("\nDELETED %d ",tem->data);
free(tem);
}
break;
case 3: if(head->link==NULL)
{
printf("\nQueue is EMPTY\n");
}
else
{
temp=head->link;
while(temp!=NULL)
{
printf("%d <-",temp->data);
temp=temp->link;
}
printf(" NULL");
}
break;
}
}while(cho==1 || cho==2 || cho==3);
}