#include #include #define MAX 50 char infix[MAX]; char postfix[MAX]; int stack[MAX]; int top; int push(int symbol) { if(top > MAX) { printf("Stack overflow\n"); return -1; } else { top=top+1; stack[top] = symbol; } return 1; } int getweight(char symbol ) { switch(symbol) { case '(': return 0; case '+': case '-': return 1; case '*': case '/': case '%': return 2; case '^': return 3; } } int pop() { if (top==-1) { printf("Stack underflow \n"); return -1; } else return (stack[top--]); } void infix2postfix() { int i,type,weight; int p=0; char next ; stack[top]='#'; int len=strlen(infix); for(i=0;i