-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathP-86.c
41 lines (41 loc) · 786 Bytes
/
P-86.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
//wap in c to implement stack data structure using array
#include<stdio.h>
int data[5];
int top=-1;
void push(int value)
{
if(top>4)
printf("\nStack Overflows insertion not possible");
else{
top++;
data[top] =value;
}
}
void pop()
{
if(top == -1)
printf("\nStack Underflows deletion is not possible.");
else{
printf("\nDeleted : %d", data[top]);
top--;
}
}
int main()
{
push(20);
push(10);
push(30);
push(40);
push(45);
printf("\nStack elements are:");
for(int i=0;i<=top;i++)
{
printf("\n%d",data[i]);
}
pop();
printf("\nNew Stack elements are:");
for(int i=0;i<=top;i++)
{
printf("\n%d",data[i]);
}
}