-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.c
More file actions
79 lines (60 loc) · 1 KB
/
Copy pathstack.c
File metadata and controls
79 lines (60 loc) · 1 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
68
69
70
71
72
73
74
75
76
77
78
//coded by:- Aditya Biswal
//Register number:- 2147207
//Program:- Implementing stack using array
//including header files:-->
#include<stdio.h>
#define size 5
int S[size+1];
int top = 0;
//making of the empty condition function:-->
int is_empty(){
if(top==0)
{
return 1;
}
else{
return 0;
}
}
//making of the push function:-->
void push(int x){
top = top + 1;
if(top>size){
printf("\nstack overflow");
}
else{
S[top] = x;
}
}
//making of the pop function:-->
int pop(){
if(is_empty()){
printf("Stack underflow\n");
return -1000;
}
else{
top = top-1;
return S[top+1];
}
}
//starting the main function:-->
int main(){
//pop();
push(10);
push(20);
push(30);
push(40);
push(50);
push(60);
push(70);
push(80);
push(90);
push(100);
//push(110);
pop();
int i;
for(i=1;i<=size;i++){
printf("%d\n",S[i]);
}
return 0;
}