File tree 1 file changed +75
-0
lines changed
1 file changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+ int stack [15 ];
3
+ int top = -1 ;
4
+ void creation (int item )
5
+ {
6
+ top = top + 1 ;
7
+ stack [top ]= item ;
8
+ }
9
+ void display ()
10
+ {
11
+ int i ;
12
+ for (i = top ;i >=0 ;i -- )
13
+ {
14
+ printf ("%d\n" ,stack [i ]);
15
+ }
16
+ }
17
+ void push ()
18
+ {
19
+ int a ;
20
+ printf ("Enter new element : " );
21
+ scanf ("%d" ,& a );
22
+ if (top == 14 )
23
+ {
24
+ printf ("Overflow" );
25
+ }
26
+ else
27
+ {
28
+ top = top + 1 ;
29
+ stack [top ]= a ;
30
+
31
+ }
32
+ }
33
+ void pop ()
34
+ {
35
+ int old ;
36
+ stack [top ]= old ;
37
+ top = top - 1 ;
38
+ printf ("Deleted element= %d" ,old );
39
+ }
40
+ int main ()
41
+ {
42
+ int item ,i ,n ,selection ;
43
+ label :
44
+ printf ("Enter 1 to create" );
45
+ printf ("\nEnter 2 to display" );
46
+ printf ("\nEnter 3 to insert an element" );
47
+ printf ("\nEnter 4 to delete an element" );
48
+ printf ("\nyour selection" );
49
+ scanf ("%d" ,& selection );
50
+ if (selection == 1 )
51
+ {
52
+ printf ("Enter elements\n" );
53
+ for (i = 0 ;i < 5 ;i ++ )
54
+ {
55
+ scanf ("%d" ,& item );
56
+ creation (item );
57
+ }
58
+ goto label ;
59
+ }
60
+ if (selection == 2 )
61
+ {
62
+ display ();
63
+ goto label ;
64
+ }
65
+ if (selection == 3 )
66
+ {
67
+ push ();
68
+ goto label ;
69
+ }
70
+ if (selection == 4 )
71
+ {
72
+ pop ();
73
+ goto label ;
74
+ }
75
+ }
You can’t perform that action at this time.
0 commit comments