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 5.2

 #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;

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 5.2

 #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();
 } 



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();
 } 

And we're supposed to read 309 lines of uncommented, unformatted code and do what with it?

Try adding more output statements at key places (top/bottom of functions, in loops) to pinpoint where the problem is.

And format your code properly. If I have to read it, I have to be able to follow it.

And learn how to do proper member variable initialization in C++ constructors!

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.