2 Stack
2 Stack
value);
stack[top--]; return
poppedValue;
empty\n");
are: ");
for (int i i top; {
prin ("%d ", stack[i]);
int main() {
push(30); push(40);
push(50);
push(60);
display();
empty\n");
return O;
OUTPUT
10 pushed to stack
20 pushed to stack
30 pushed to stack
40 pushed to stack
50 pushed to stack
Popped element: 50
Popped element:
40 Stack is not
empty 70 pushed
to stack
80 pushed to stack
PART 2:
#include <stdio.h>
#include <string.h>
stack[top--];
return '\O';
so not balanced
&& topChar I l
return isEmpty(); // Return true if stack is empty, meaning all parentheses are
matched
b) * (c +
char
expr3[] -
char
%s\n", exprl);
return O;
OUTPUT
Expression: (a + b) * (c + d)
Balanced: Yes
Expression: (a + b) * (c + d))
Balanced: No