-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack2.c
More file actions
59 lines (59 loc) · 992 Bytes
/
Stack2.c
File metadata and controls
59 lines (59 loc) · 992 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
54
55
56
57
58
59
/*
* Stack2.c
*
* Created on: 20 Jul 2024
* Author: ABHISHEK
*/
//wap in c that a sequence of pop and push operations and an integer representing and an integer representing the size of an array in which a stack is to be implemented ,design an algorithm to determine whether or not overflow occurs.The algorithm should not use a stack .
//
#include<stdio.h>
#include<conio.h>
#include <stdlib.h>
#define stacksize 100
int top=-1;
void push()
{
top++;
printf("\nTop =%d",top);
if(top>=stacksize)
{
printf("\nOverflow ");
}
}
void pop()
{
top--;
printf("\nTop = %d",top);
if(top<=-1)
{
printf("\nUndeflow");
}
}
void s()
{
int a=-1;
while(a==-1)
{
int b;
printf("\nEnter option \n1 Push\n2 Pop\n3 Exit\n");
scanf("%d",&b);
switch(b)
{
case 1:
push();
break;
case 2:
pop();
break;
case 3:
exit(0);
break;
}
}
getch();
}
int main()
{
s();
return 0;
}