-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExecution_Analyzer.c
More file actions
40 lines (34 loc) · 941 Bytes
/
Execution_Analyzer.c
File metadata and controls
40 lines (34 loc) · 941 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
#include <stdio.h>
#define SIZE 5
int main() {
int stack[SIZE], top = -1;
int choice, value;
while(1) {
printf("\n1.Push 2.Pop 3.Display 4.Exit\n");
scanf("%d", &choice);
switch(choice) {
case 1:
if(top == SIZE - 1) {
printf("Stack Overflow\n");
} else {
scanf("%d", &value);
stack[++top] = value;
}
break;
case 2:
if(top == -1) {
printf("Stack Underflow\n");
} else {
printf("Popped: %d\n", stack[top--]);
}
break;
case 3:
for(int i = top; i >= 0; i--)
printf("%d ", stack[i]);
printf("\n");
break;
case 4:
return 0;
}
}
}