-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20.Multiple_Stack.c
More file actions
89 lines (78 loc) · 2.04 KB
/
20.Multiple_Stack.c
File metadata and controls
89 lines (78 loc) · 2.04 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
81
82
83
84
85
86
87
88
89
/* Name:Shylesh S
Roll No: 47
Program No. 20
Program: Multiple Stack */
#include<stdio.h>
#include<stdlib.h>
void main()
{
int arr[40],top1=0,top2=40,cho,i;
do
{
printf("\nMENU\n\nSTACK 1 STACK 2");
printf("\n1.PUSH 4.PUSH");
printf("\n2.POP 5.POP");
printf("\n3.DISPLAY 6.DISPLAY");
printf("\n 7.EXIT");
printf("\nEnter Choice: ");
scanf("%d",&cho);
if(cho==1)
{
top1=top1+1;
printf("enter the element: ");
scanf("%d",&arr[top1]);
printf("element pushed!!!");
}
else if(cho==2)
{
if(top1==0)
{
printf("stack is empty!!!");
}
else
{
printf("popped out: %d",arr[top1]);
arr[top1]=NULL;
top1-=1;
}
}
else if(cho==3)
{
printf("elements: ");
for(i=top1;i>0;i--)
{
printf("%d |->",arr[i]);
}
printf("NULL");
}
else if(cho==4)
{
top2=top2-1;
printf("enter the element: ");
scanf("%d",&arr[top2]);
printf("element pushed!!!");
}
else if(cho==5)
{
if(top2==40)
{
printf("stack is empty!!!");
}
else
{
printf("popped out: %d",arr[top2]);
arr[top2]=NULL;
top2+=1;
}
}
else if(cho==6)
{
printf("elements: ");
for(i=top2;i<40;i++)
{
printf("%d |->",arr[i]);
}
printf("NULL");
}
}while(cho==1 || cho==2 || cho==3 || cho==4 ||cho==5 || cho==6);
}