forked from Aniket965/Hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PRACQUE.CPP
102 lines (101 loc) · 1.25 KB
/
PRACQUE.CPP
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<stdio.h>
struct customer
{
int cnum;
char cname[30];
};
const int max=20;
customer c[10];
int front=-1,rear=-1;
void insert(customer c[],customer ele)
{
if(front==-1)
{
front=rear=0;
c[0]=ele;
}
else if(rear==max-1)
{
cout<<"Over flow\n";
}
else
{
c[++rear]=ele;
}
}
int del()
{
if(front==-1)
{
cout<<"underflow\n";
}
else if(front==rear)
{
front=rear=-1;
}
else
{
front++;
}
}
void display(customer c[],int front,int rear)
{
if(front==-1)
{
cout<<"Underflow\n";
}
else
{
for(int i=front;i<=rear;i++)
{
cout<<c[i].cnum;
puts(c[i].cname);
}
}
/*cout<<c[rear].cnum;
puts(c[i].cname);*/
}
void main()
{
clrscr();
int ch;
customer c1;
do
{
cout<<"1.Insertion\n";
cout<<"2.Deletion\n";
cout<<"3.Display\n";
cout<<"4.EXIT\n";
cin>>ch;
if(ch==1)
{
cout<<"Enter the data of the customer\n";
cout<<"1.Customer Number\n";
cout<<"2.Customer name\n";
cin>>c1.cnum;
gets(c1.cname);
insert(c,c1);
getch();
}
else if(ch==2)
{
cout<<"Deletion\n";
del();
getch();
}
else if(ch==3)
{
cout<<"Dispalying\n";
display(c,front,rear);
getch();
}
else if(ch==4)
{
exit(0);
}
}
while(ch>=1&&ch<=4);
}