this is my input and i get the correct output for post fix , i get this really large number for the out of it and i dont know why.
Enter the damn infix expression:
1+2
postfix is 12+
----------------------------------------
answer is:2665328 <--- trying to calculate
this is my calculate function
-----------------------------------------
int calculate(string p)
{
int calc [3];
int count=0;
char first;
int f;
int a;
int b;
for(int i=0; i< p.length();i++){
first= p[i];
f = (int)first;
a=calc[count-1];
b=calc[count-2];
cout<<"a:"<< a << "b:" << b;
if(ope(p[i])==true){
if(p[i]=='^'){
count=count-2;
calc[count] =pow(b,a);
count++;
}
if(p[i]=='*'){
count=count-2;
calc[count] =b*a;
count++;
}
if(p[i]=='/'){
count=count-2;
calc[count] =b/a;
count++;
}
if(p[i]=='+'){
count=count-2;
calc[count] =b+a;
count++;
}
if(p[i]=='-'){
count=count-2;
calc[count] =b-a;
count++;
}
calc[count]=(f);
count++;
}
}
sum=calc[0];
return sum;
}