Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

Write a C++ program to evaluate postfix expressions. Your program should take postfix expression as an input, process it with the help of stack and display the result after performing required calculations.

 

Only following Binary operators are allowed for this program:

+, -, *, /, ^ [addition, subtraction, multiplication, division, exponentiation]

 

If some error occurs while processing postfix expression, your program should display a meaningful message, like:

Error: Division by zero not allowed

Error: Two operands required for __ operator

Error: Invalid postfix expression

 

Sample Run:

Enter postfix expression to evaluate:

10 20 +                                                         Entered by user 

 

The result is: 30

 

Do you want to enter another postfix expression to evaluate? [Y/N]

Y                                                                    Entered by user

 

Enter postfix expression to evaluate:

30 40 + *                                                      Entered by user

 

Error: Two operands required for * operator

 

Do you want to enter another postfix expression to evaluate? [Y/N]

Y                                                                      Entered by user

 

Enter postfix expression to evaluate:

30 40 + 50 60 *                                              Entered by user

 

Error: Invalid postfix expression

 

Do you want to enter another postfix expression to evaluate? [Y/N]

Y                                                                       Entered by user

 

Enter postfix expression to evaluate:

6 2 3 + - 3 8 2 / + * 2 ^ 3 +                            Entered by user

 

The result is: 52

 

Do you want to enter another postfix expression to evaluate? [Y/N]

N                                                                      Entered by user

 

Thank you for using this program.

Lectures Covered:  This assignment covers Lecture # 5-9

Deadline:                  Your assignment must be uploaded/submitted at or before 17-Nov-2011.

 

Views: 894

Replies to This Discussion

Please Discuss here about this assignment.Thanks

See the attached file for complete assignment.

Attachments:

See the attached file for idea solution of CS301 assignment#02 fall 2011

Attachments:

plz right solution share krain.................

See the attached file for another idea solution of CS301 Assignment#02 Fall 2011

Attachments:

Please share me2complete solution..........

One more idea solution of CS301 Assignment#02 Fall 2011

Attachments:

it has also many errors please correct them i also try my level best to solve them

please please some one have the right solution?

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service