11-17-2011, 06:50 PM
Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit (zero marks) if:
o The assignment is submitted after due date.
o The submitted code does NOT compile.
o The submitted assignment does NOT open or file corrupt.
o The assignment is copied (from other student or ditto copy from handouts or internet).
Uploading instructions
Your Submission must include:
Note: Use Dev-C++ IDE.
Objective
The objective of this assignment is
o To give you some practice exercise of Stack Data Structure.
For any query about the assignment, contact at cs301@vu.edu.pk
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.
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit (zero marks) if:
o The assignment is submitted after due date.
o The submitted code does NOT compile.
o The submitted assignment does NOT open or file corrupt.
o The assignment is copied (from other student or ditto copy from handouts or internet).
Uploading instructions
Your Submission must include:
- A working Make File (Dev-C++ project File).
- All the Source Code (.h and .cpp files) necessary to compile and run your program.
- Place all the files in a folder then Zip this folder and Upload it on VU-LMS
Note: Use Dev-C++ IDE.
Objective
The objective of this assignment is
o To give you some practice exercise of Stack Data Structure.
For any query about the assignment, contact at cs301@vu.edu.pk
GOOD LUCK
Marks: 20
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.
