-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.c
More file actions
61 lines (61 loc) · 1.1 KB
/
Copy pathstack.c
File metadata and controls
61 lines (61 loc) · 1.1 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
#include <stdio.h>
void push();
void pop();
void display();
int item,top=-1,A[20],i,maxsize;
void main()
{
int ch;
printf("Enter limit:");
scanf("%d",&maxsize);
while(ch!=4)
{
printf("Enter choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:push();
break;
case 2:pop();
break;
case 3:display();
break;
case 4:break;
}
}
}
void push()
{
if(top==maxsize-1)
{
printf("Overflow\n");
}
else
{
printf("Element to be pushed:");
scanf("%d",&item);
top++;
A[top]=item;
}
}
void pop()
{
if(top==-1)
{
printf("Underflow\n");
}
else
{
A[top] = item;
top--;
printf("Deleted item is %d\n",item);
}
}
void display()
{
printf("Stack is:");
for(i=top;i>=0;i--)
{
printf("%d\n",A[i]);
}
}