StackArrayImplementation C
StackArrayImplementation C
DSA LAB\StackArrayImplementation.c
localhost:51970/9d0aee79-9e55-4a94-ace7-824b5f23d77b/ 1/4
17/01/2024, 02:30 StackArrayImplementation.c
58 printf("\nEnter the element to be added on stack: ");
59 scanf("%d",&val);
60 push(stack,val);
61 break;
62 case 2:
63 val=pop(stack);
64 if(val!=-1)
65 printf("\nThe element is removed from the stack: %d",val);
66 break;
67 case 3:
68 peek(stack);
69 break;
70 case 4:
71 display(stack);
72 }
73 }while(option!=5);
74
75 }
76
77 //Output:
78 /*
79
80 *****Main Menu*****
81 1. PUSH
82 2. POP
83 3. PEEK
84 4. DISPLAY
85 5. EXIT
86 Enter your option: 1
87
88 Enter the element to be added on stack: 5
89
90 *****Main Menu*****
91 1. PUSH
92 2. POP
93 3. PEEK
94 4. DISPLAY
95 5. EXIT
96 Enter your option: 1
97
98 Enter the element to be added on stack: 9
99
100 *****Main Menu*****
101 1. PUSH
102 2. POP
103 3. PEEK
104 4. DISPLAY
105 5. EXIT
106 Enter your option: 1
107
108 Enter the element to be added on stack: 8
109
110 *****Main Menu*****
111 1. PUSH
112 2. POP
113 3. PEEK
114 4. DISPLAY
115 5. EXIT
116 Enter your option: 1
117
localhost:51970/9d0aee79-9e55-4a94-ace7-824b5f23d77b/ 2/4
17/01/2024, 02:30 StackArrayImplementation.c
118 Enter the element to be added on stack: 2
119
120 Stack Overflow
121 *****Main Menu*****
122 1. PUSH
123 2. POP
124 3. PEEK
125 4. DISPLAY
126 5. EXIT
127 Enter your option: 4
128
129 8
130 9
131 5
132 *****Main Menu*****
133 1. PUSH
134 2. POP
135 3. PEEK
136 4. DISPLAY
137 5. EXIT
138 Enter your option: 2
139
140 The element is removed from the stack: 8
141 *****Main Menu*****
142 1. PUSH
143 2. POP
144 3. PEEK
145 4. DISPLAY
146 5. EXIT
147 Enter your option: 2
148
149 The element is removed from the stack: 9
150 *****Main Menu*****
151 1. PUSH
152 2. POP
153 3. PEEK
154 4. DISPLAY
155 5. EXIT
156 Enter your option: 2
157
158 The element is removed from the stack: 5
159 *****Main Menu*****
160 1. PUSH
161 2. POP
162 3. PEEK
163 4. DISPLAY
164 5. EXIT
165 Enter your option: 3
166
167 Stack is empty.
168 *****Main Menu*****
169 1. PUSH
170 2. POP
171 3. PEEK
172 4. DISPLAY
173 5. EXIT
174 Enter your option: 2
175
176 Stack Underflow
177 *****Main Menu*****
localhost:51970/9d0aee79-9e55-4a94-ace7-824b5f23d77b/ 3/4
17/01/2024, 02:30 StackArrayImplementation.c
178 1. PUSH
179 2. POP
180 3. PEEK
181 4. DISPLAY
182 5. EXIT
183 Enter your option: 5
184 PS C:\Users\iraki\Desktop\My Program\DSA LAB>
185 */
localhost:51970/9d0aee79-9e55-4a94-ace7-824b5f23d77b/ 4/4