xprt bachy kitnimintain ker rahy hain plz upload the solution file as soon as possible
plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
const int size =50;
char infix[size],postfix[size],stack[size];
int top=-1;
int precedence(char ch); // function to get the precedence of the operator
char pop(); //function to pop an element from the stack
char topelement(); // returns the top element of the stack
void push(char ch); // pushes an element into the stack
int main()
{
char ele,elem,st[2];
int prep,pre,popped,j=0,chk=0;
strcpy(postfix," ");
gets(infix);
for(int i=0;infix[i]!=0;i++)
{
if(infix[i]!='('&&infix[i]!=')'&&infix[i]!='^'&&infix[i]!='*'&&infix[i]!='/'&&infix[i]!='+'&&infix[i]!='-')
postfix[j++]=infix[i];
else if(infix[i]=='(')
{
elem=infix[i];
push(elem);
}
else if(infix[i]==')')
{
while(popped=pop() != '(')
postfix[j++]=popped;
}
else
{
elem=infix[i];
pre=precedence(elem);//stores the precedence of operator coming frm infix
ele=topelement();
prep=precedence(ele);//stores the precedence of operator at the top of the stack
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: oThe assignment is submitted after due date. o The submitted code does NOT compile. oThe submitted assignment does NOT open or file corrupt. oThe 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 oTo 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
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.