forked from Manish57-droid/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDYNAQUE.C
More file actions
80 lines (80 loc) · 1.28 KB
/
DYNAQUE.C
File metadata and controls
80 lines (80 loc) · 1.28 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
72
73
74
75
76
77
78
79
80
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
struct node
{
int info;
struct node *next;
}*rear=NULL,*front=NULL;
void main()
{
int ch;
clrscr();
while(1)
{
printf("\n1.Insert item");
printf("\n2.Delete item");
printf("\n3.Display");
printf("\n4.Quit");
printf("\nEnter your choice=");
scanf("%d",&ch);
switch(ch)
{
case 1:
insert_item();
break;
case 2:
del_item();
break;
case 3:
display();
break;
case 4:
exit(1);
default:
printf("\n Wrong choice Try again!!!!");
}
}
}
insert_item()
{
struct node *temp;
int item;
temp=(struct node *)malloc(sizeof(struct node));
printf("\n Enter item to be inserted= ");
scanf("%d",&item);
temp->info=item;
temp->next=NULL;
if(front==NULL)
front=temp;
else
rear->next=temp;
rear=temp;
}
del_item()
{
struct node *temp;
if(front==NULL)
printf("\n Queue underflow");
else
{
temp=front;
printf("\n Element after deletion is=%d",temp->info);
front=front->next;
free(temp);
}
}
display()
{
struct node *trav;
if(front==NULL)
printf("\n Queue is empty");
else
{
printf("\ncontents of queue are=\n");
for(trav=front;trav!=NULL;trav=trav->next)
{
printf("%d",trav->info);
}
}
}