can any one tell me whats the problem in evaluation of postfix

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<math.h>
#define MAX 20
char stack[MAX];
int top=-1;
char pop();
void push(char val);


int prcd(char symbol)
{
 switch(symbol)
 {
  case '+':
  case '-':
   return 2;
  case '*':
  case '/':
   return 4;
  case '^':
  case '$':
   return 6;
  case '(':
  case ')':
  case '#':
   return 1;
 }
}


int isoperator(char symbol)
{
 switch(symbol)
 {
 case '+':
 case '-':
 case '*':
 case '/':
 case '^':
 case '$':
 case '(':
 case ')':
  return 1;
 default:
  return 0;
 }
}

void convertip(char infix[],char postfix[])
{
 int i,j=0;
 char symbol;
 stack[++top]='#';

 for(i=0;i<strlen(infix);i++)
 {
  symbol=infix[i];
  if(isoperator(symbol)==0)
  {
   postfix[j]=symbol;
   j++;
  }
  else
  {
   if(symbol=='(')
    push(symbol);
   else if(symbol==')')
   {
    while(stack[top]!='(')
    {
     postfix[j]=pop();
     j++;
    }
   pop();
   }
   else
   {
    if(prcd(symbol)>prcd(stack[top]))
     push(symbol);
    else
    {
     while(prcd(symbol)<=prcd(stack[top]))
     {
      postfix[j]=pop();
      j++;
     }
     push(symbol);
    }//end of else
   } //end of else
  }//end of else
 }//end of for
 while(stack[top]!='#')
 {
  postfix[j]=pop();
  j++;
 }
 postfix[j]='\0'; //null terminate string
}//end of function

void main()
{
 char infix[20],postfix[20];
 clrscr();
 cout<<endl<<"Enter the valid infix string:";
 gets(infix);
 convertip(infix,postfix);
 cout<<endl<<"The corresponding postfix string is:";
 puts(postfix);
 int i=0;
 char a,b,c;
 while(postfix[i]!='\0')
 {
 if(isdigit(postfix[i])||isalpha(postfix[i]))
 push(postfix[i]-48);
 else if(postfix[i]!=32)
 {
 a=pop();
 b=pop();
 if(postfix[i]=='*')
   c=b*a;
 else if(postfix[i]=='/')
   c=b/a;
 else if(postfix[i]=='+')
  c=b+a;
 else if(postfix[i]=='^')
  c=pow(b,a);
 else
  c=b-a;
 push(c);
 }
 i++;
 }
 cout<<endl<<c;

 getch();
}

void push(char val)
{
stack[++top]=val;
}
char pop()
{
return stack[top--];
}

- Please use code tags and reasonable indentation.

- Please tell us an example input, the current output, and the expected output.

Dave

Thankyou for ur interest of helping me but i have solved my prob
i will ask u if i have any other problem thanks again

Please post your solution so others can benefit from a future search.

Also, please mark the thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.