forked from keshavsingh4522/c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack_push_pop.cpp
45 lines (44 loc) · 957 Bytes
/
stack_push_pop.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
#include"conio.h"
#include"stdio.h"
#include"process.h"
void main()
{
clrscr();
int stack[10],i,push,c,k=1;
printf("enter no ofelements in array: ");
scanf("%d",&push);
printf("enter elemens in array: \n");
for(i=0;i<push;i++)
scanf("%u",stack+i);
do
{
printf("\nenter 1 to push: ");
printf("\nenter 0 to out from the loop");
scanf("%d",&k);
if(k==1)
{printf("enter element to push: ");
scanf("%d",&stack[push]);
push++;}
}while(k);
printf("after push list is: \n");
for(i=0;i<push;i++)
printf("%d ",i[stack]);
do
{
push--;
printf("\nenter 1 to pop: \n");
printf("enter 2 to exit: \n");
if(push==0)
printf("no element in list");
scanf("%d",&c);
if(c==1&&push!=0)
{
printf("after poping ur stack list is: \n");
for(i=0;i<push;i++)
printf("%d ",stack[i]);
}
else
exit(0);
}while(1);
getch();
}