-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.c
More file actions
67 lines (63 loc) · 1.24 KB
/
stack.c
File metadata and controls
67 lines (63 loc) · 1.24 KB
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
60
61
62
63
64
65
66
67
/*********************************
file : Stack
author : Ashly Rose Antony
version : 1.0
date : 3/12/21
**********************************/
#include<stdio.h>
int i;
int max=10;
void push(int[],int);
void pop(int[],int);
int main(){
int myStack[10],option,top=-1;
do{
printf("\n\n\nChoose your option\n");
printf("1.Push Operation\n2.Pop Operation\n3.Exit\n");
scanf("%d",&option);
if(option==1){
push(myStack,top);
top++;
}
else if(option==2){
pop(myStack,top);
top=top-1;
}
else{
printf("\nThank u");/*********************************
file : Sparse matrix
author : Ashly Rose Antony
version : 1.0
date : 3/12/21
**********************************/
}
}while(option==1||option==2);
return 0;
}
void push(int stackArray[10],int top){
if(top==max){
printf("Stack is full\n");
}
else{
top=top+1;
printf("Enter the value\n");
scanf("%d",&stackArray[top]);
printf("Your Stack :- \n");
for(i=0;i<=top;i++){
printf("%d ",stackArray[i]);
}
}
}
void pop(int stackArray[10],int top){
if(top<0){
printf("Stack is empty\n");
}
else{
printf("\nDeleting element = %d\n",stackArray[top]);
top=top-1;
printf("Your Stack :- \n");
for(i=0;i<=top;i++){
printf("%d ",stackArray[i]);
}
}
}