title: PostFix Expression Evaluation
body: <p>I'm a writing a C++ program to Evaluate a PostFIx expression. This is the following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;stack&gt;
  #include &lt;conio.h&gt;
  
  using namespace std;
  
  int operand1;
  int operand2;
  
  bool operator_test(char character){ //to test whether its an operator or not
      if(character=='+' || character=='-' || character=='*' || character=='/')
          return true;
      else
          return false;
  }
  
  bool operand_test(char character){ //to test whether its an operand or not
      if(!operator_test(character) &amp;&amp; character!='(' &amp;&amp; character!=')')
              return true;
      else
          return false;
  }
  
  int DoOperation(char operation,int operand1,int operand2){
      if(operation=='+') return operand1+operand2;
      else if(operation=='-') return operand1-operand2;
      else if(operation=='*') return operand1*operand2;
      else if(operation=='/') return operand1/operand2;
  }
  
  
  int main(){
      string expression;
      cout&lt;&lt;"ENTER POSTFIX EXPRESSION"&lt;&lt;endl;
      cin&gt;&gt;expression;
      stack&lt;int&gt;test_stack;
      int result;
      for(int i=0;i&lt;expression.length();i++){
  
          if(operand_test(expression[i]))
              test_stack.push(expression[i]);
          else if(operator_test(expression[i]))
              operand2=test_stack.top();
  
          test_stack.pop();
          operand1=test_stack.top();
          test_stack.pop();
          result=DoOperation(expression[i],operand1,operand2);
          test_stack.push(result);
      }
  
      cout&lt;&lt;"EVALUATION: "&lt;&lt;test_stack.top()&lt;&lt;endl;
      getch();
      return 0;
  }
  </code></pre>
  
  <p>If I enter 23+ it should give 5 as output. But it's giving 51. What am I doing wrong here??
  thanks in advance</p>