ds_exp_3
ds_exp_3
N
Class : Second Year
Roll no: 66 Div: B
Course Code: CEC303
Experiment no: 3
CODE:
include <stdio.h>
#
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
typedef struct {
int top;
int items[MAX];
} Stack;
hile (*p) {
w
if (isspace(*p)) {
p++;
continue;
}
if (isdigit(*p)) {
push(&s, *p - '0');
} else {
if (s.top < 1) {
printf("Error: Not enough operands for operator '%c'\n", *p);
exit(EXIT_FAILURE);
}
if (isEmpty(&s)) {
printf("Error: No result on the stack\n");
exit(EXIT_FAILURE);
}
return pop(&s);
}
int main() {
char postfix[MAX];
OUTPUT: