#include using namespace std; template class Stack { int stacksize,top; T *astack; public: Stack(int size) { stacksize=size; astack=new T[stacksize]; top=-1; } int isEmpty() { if(top==-1) { return 1; } else { return 0; } } int isFull() { if(top==stacksize-1) { return 1; } else { return 0; } } void push(T item) { if(isFull()) { cout<<"stack is full\n"; } else { top=top+1; astack[top]=item; } } T pop() { if(isEmpty()) { cout<<"stack is empty\n"; } else { T val; val=astack[top]; top=top-1; return val; } } T getstacktopval() { return astack[top]; } }; int operatorpre(char op) { int pre; switch(op) { case '+': case '-': pre=1; break; case '*': case '/': pre=2; break; } return pre; } int main() { Stacks(20); char infix[20],postfix[20]; cout<<"enter the infix form\n"; cin>>infix; int **0; int j=0; while(infix[i]!='\0') { if(isalpha(infix[i])) { postfix[j]=infix[i]; i++,j++; } else { if(s.isEmpty()) { s.push(infix[i]); i++; } else { while(((operatorpre(infix[i]))<=(operatorpre(s.getstacktopval())))&&(!s.isEmpty())) { postfix[j]=s.pop(); j++; } s.push(infix[i]); i++; } } } while(!s.isEmpty()) { postfix[j]=s.pop(); j++; } postfix[j]='\0'; cout<<"the infix form is\t"<