-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathStack using array
More file actions
111 lines (56 loc) · 904 Bytes
/
Copy pathStack using array
File metadata and controls
111 lines (56 loc) · 904 Bytes
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
102
103
104
105
106
107
108
109
110
111
#include <stdio.h>
int main()
{
int A[10],ele,i,top=-1,ch; do
{
printf("Enter your choice\n");
printf("Press 1 for insertion\nPress 2 for deletion\nPress 3 for display\nPress 4 gor quit\n");
scanf("%d",&ch);
if(ch==1) //insertion
{
if(top==9)
{
printf("Insertion is not possible\n");
}
else
{
top++;
printf("Enter the element\n");
scanf("%d",&ele);
A[top]=ele;
}
}
else if(ch==2) //deletion
{
if(top==-1)
{
printf("Deletion is not possible\n");
}
else
{
printf("%d is deleted\n",A[top]);
top--;
}
}
else if(ch==3) //display
{
if(top==-1)
{
printf("No element in stack\n");
}
else
{
for(i=top;i>=0;i--)
{
printf("%d\t",A[i]);
}
printf("\n");
}
}
else //quit
{
exit (0);
}
}while(ch!=4);
return 0;
}