-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path18_stackarray.c
50 lines (43 loc) · 967 Bytes
/
18_stackarray.c
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
//Govind J Nair
//S3-D
//23
#include<stdio.h>
#include<stdlib.h>
void main()
{
int arr[15],top=0,cho,i;
do
{
printf("\nMENU\n1.PUSH\n2.POP\n3.DISPLAY\n4.EXIT\nEnter Choice: ");
scanf("%d",&cho);
if(cho==1)
{
top=top+1;
printf("enter the element: ");
scanf("%d",&arr[top]);
printf("element pushed!!!");
}
else if(cho==2)
{
if(top==0)
{
printf("stack is empty!!!");
}
else
{
printf("popped out: %d",arr[top]);
arr[top]=0;
top-=1;
}
}
else if(cho==3)
{
printf("elements: ");
for(i=top;i>0;i--)
{
printf("%d |->",arr[i]);
}
printf("NULL");
}
}while(cho==1 || cho==2 || cho==3);
}