#include<iostream.

h>
#include<conio.h>
#include<ctype.h>
#include<string.h>
class infix
{
char *s,*t;
int top,i;
char stack[50];
public:
infix()
{
top=-1;
s=new char[50];
t=new char[50];
strcpy(stack,"");
i=0;
}
void setxpr(char *str)
{
strcpy(s,str);
}
void push(char c)
{
if(top==49)
cout<<"stack overflow";
else
{
top++;
stack[top]=c;
}
}
char pop()
{
if(top==-1)
{
cout<<"stack underflow";
return 0;
}
else
{
char item=stack[top];
top-=1;
return item;
}
}
void convert()
{
while(*s!='\0')
{
if((*s==' ')||(*s=='\t'))
{
s++;
continue;
}
if((isdigit(*s))||(isalpha(*s)))
{

while((isdigit(*s))||(isalpha(*s))) { *t=*s. } s++. } if(*s=='(') { push(*s). else break. t++. while(opr!='(') { *t=opr. if(priority(opr)>=priority(*s)) { while(priority(opr)>=priority(*s)) { *t=opr. } continue. t++. }else { . opr=pop(). s++. continue. s++. i++. continue. t++. } if(top!=-1) { char opr = pop(). continue. } if(*s==')') { char opr=pop(). i++. } push(*s). if(top!=-1) opr=pop(). i++. s++.

} } while(top!=-1) { char opr = pop(). *t=opr.i>=0.getline(st. } } else { push(*s). t++. if((c=='+')||(c=='-')) return 1. } *t='\0'. cin. } } }. s++. push(*s). continue. s++. infix q. else return 0. cout<<"enter expr:". . int main() { char st[50]. } int priority(char c) { if(c=='^') return 3.push(opr). continue. } void show() {for(.i--) { cout<<*(t-i). if((c=='*')||(c=='/')||(c=='%')) return 2.50). i++.

q. q. cout<<"\npostfix is ". } .q.show().convert(). return 0.setxpr(st).