Evaluation of Postfix Expression Using Stacks! (Not Working)

Here is my complete code. I have really tried everything but couldn't understand where i am going wrong. There is NO ERROR in compilation but the output does take in the elements and output is not being generated. My compiler is Borland 10.5

#include <iostream>
#include <conio>

class ListStack
{
private:
struct node
{

int num;
node *next;
}*top;
int operand_count;

public:

ListStack()
{
top=NULL;
}

int push(int);
int pop();
void display();
void get_expression();
int get_value(int);

};

int ListStack::push(int c)
{
node *temp;
temp = new node;
temp->num=c;
temp->next=top;
top=temp;
return c;

}

int ListStack::pop()
{ int c;
if(top==NULL)
cout<<"Stack UnderFlow"<<endl;
else
{
node *temp;
temp=top;
cout<<"deleted Number from the stack = ";
c=top->num;
top=top->next;
//return (temp->num);
delete temp;
return (c);
}
}


void ListStack::display()
{ node*temp;
temp=top;
while(temp!=NULL)
{
cout<<"\n"<<temp->num<<endl;
temp=temp->next;
}
}

int ListStack::get_value(int c)
{ int operand_count;
cout<<"how many number of operands you have?";
cin>>operand_count;
int numeric_array[5];
int i;

for (i=0;i<=operand_count;i++)
{
cout<<"Enter Value: ";
cin>>numeric_array[i];
//return numeric_array;
}
}

void ListStack::get_expression()
{
char save;
int i=0;
int first_operand, second_operand, result;
char postfix_array[50], No_operator[50];
cout<<"Enter the numeric Postfix expression: ";
cin.getline(postfix_array,50);

while (postfix_array[i]!='\0')
save=postfix_array[i];
if (save!= '+' && save!= '-' && save!= '*' &&save!= '/' &&save!= '^')
{

for(i=0; i<=50; i++)
{
cout<<"\n ENter operator :";
cin>>No_operator[i];
get_value( No_operator[i]);
}

while (No_operator[i]!='\0')

push( No_operator[i]);

}
else
first_operand = pop();
second_operand = pop();
switch(save)
{
case '+':
result=first_operand + second_operand;
cout<<result;
push(result);
break;

case '-':
result=first_operand - second_operand;
cout<<result;
push(result);
break;

case '*':
result=first_operand * second_operand;
cout<<result;
push(result);
break;

case '/':
result=first_operand / second_operand;
cout<<result;
push(result);
break;

case '%':
result=first_operand % second_operand;
cout<<result;
push(result);
break;
}
}

void main()
{
ListStack LS;
LS.get_expression();
LS.display();
getche();
}
Hi! Code tags pls :)
Should those while loops have {} ?
Topic archived. No new replies allowed.