-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack_Implementation.c
More file actions
53 lines (46 loc) · 841 Bytes
/
Stack_Implementation.c
File metadata and controls
53 lines (46 loc) · 841 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
#include <stdio.h>
int ele=0;
long int cho;
int count=0;
int main(int argc, char const *argv[])
{
long int stack[5];
printf(" =>Chose 1 to PUSH\n");
printf(" =>Chose 2 to POP \n");
printf(" =>Chose 3 to Show The Stack \n");
printf(" =>Chose 4 to EXIT \n");
while(1)
{
printf("Your Choise: ");
scanf("%ld",&cho);
if (cho==1){
printf("Element to push: \n");
scanf("%ld",&stack[ele]);
ele++;
count++;
}
else if (cho==2){
ele--;
}
else if (cho==3)
{
if (count%2==0)
{
for (int i=ele-1;i>=0;i--)
{
printf("%ld\n",stack[i]);
}
}
else
{
for (int i=ele-1;i>=0;i--)
printf("%ld\n",stack[i]);
}
}
else if (cho==4){
printf("Exits!!\n");
return 0;}
else
printf("Invalid Input!!!!\nTry again\n");
}
}