Micro 1
Micro 1
<4>#include<stdio.h>#include<stdlib.h>void evaluate();
j++;}
void push(char);
char pop(); push(symb);
int prec(char);char infix[30], postfix[30], stack[30]; int break;
top = -1;void main() { default:
printf("\nEnter the valid infix expression:"); postfix[j] = symb;
scanf("%s", infix); j++;}}
evaluate(); while (top > 0) {
printf("\nThe entered infix expression is :\n %s \n", infix); printf("\nThe temp = pop();
corresponding postfix expression is :\n %s \n", postfix); postfix[j] = temp;
}void evaluate() { j++;}
int i = 0, j = 0; postfix[j] = '\0';
char symb, temp;push('#');for (i = 0; infix[i] != '\0'; i++) { symb = }void push(char item) {
infix[i]; top = top + 1; stack[top]
switch (symb) { = item;
case '(': }char pop() {
push(symb); char item;
break;case ')': item = stack[top];
temp = pop(); while top = top - 1;
(temp != '(') { return item;
postfix[j] = temp; }int prec(char symb) {
j++; int p;
temp = pop();} switch (symb) {
break; case '#':p = -1;
case '+': break;case '(':
case '-': case ')':p = 0;
case '*': break;case '+':
case '/': case '-':p = 1;
case '%': break;case '*':
case '^': case '/':
case '$': case '%':p =2;
while (prec(stack[top]) >= prec(symb)) {
break;case '^':
temp = pop();
case '$':p = 3;
break;}
return p;}