Where's the solution?
InstructionsView more random threads:
- MTH401 Differential Equations Assignment No.1 Solution...
- CS403 Database Management Systems Assignment No.2 Fall...
- cs506 Assignment No. 4 solution fall 2010
- First Assignment fall CS604 (Operating System) for 2012
- mth101 assignment no 1 spring 2011 idea solution by vuhelp
- cs609 idea solution here...................
- CS502 Fundamentals of Algorithms Spring 2011 ASSIGNMENT4...
- CS605 VU Current Assignment No. 4 Fall January 2012
- CS201 Introduction to Programming Assignment No. 04...
- CS301‐ Data Structures Assignment No. 1 Solution Semester...
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 assignment does not open or file corrupt.
o The assignment is copied (from other student or ditto copy from handouts or internet).
o Student ID is not mentioned in the assignment File or name of file is other than student ID.
Note: Kindly check the template file for submitting assignment. (see announcement)
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 that folder and Upload it on VULMS
Note: Use Dev-C++ 4.9.9.2 which is available at VULMS (Download section) or you can use Dev-C++ 4.0 or any other version higher than 4.0.
Question:
Write a program in c++ that takes an infix expression from user through command line argument and convert it into a postfix expression. You are required to use the stack data structure for the implementation of this task.
Note: You can’t use built-in library function or templates for stack functions. All the source code should be written manually.
Urgent call: 03455242488. | Virtual University Assignments
Virtual University GDBs | Virtual University Papers | Vu Projects | Vu Handouts
About Expert
Where's the solution?
Solution can be found after few hours.
Sponsored Links
IDEA Solution of cs301 second assignment
Code:#include<iostream.h> #include<string.h> #include<stdlib.h> #include<ctype.h> class expression { private: char infix[100]; char stack[200]; int top; int r; char postfix[100]; public: void convert(); int input_p(char); int stack_p(char); int rank(char); }; int expression::input_p(char c) { if(c==’+’ || c==’-') return 1; else if(c==’*’ || c==’/') return 3; else if(c==’^') return 6; else if(isalpha(c)!=0) return 7; else if(c==’(‘) return 9; else if(c==’)') return 0; else { cout<<”Invalid expression ::input error\n”; exit(0); } } int expression::stack_p(char c) { if(c==’+’ || c==’-') return 2; else if(c==’*’ || c==’/') return 4; else if(c==’^') return 5; else if(isalpha(c)!=0) return 8; else if(c==’(‘) return 0; else { cout<<”Invalid expression ::stack error\n”; exit(0); } } int expression::rank(char c) { if(c==’+’ || c==’-') return -1; else if(c==’*’ || c==’/') return -1; else if(c==’^') return -1; else if(isalpha(c)!=0) return 1; else { cout<<”Invalid expression ::in rank\n”; exit(0); } } void expression::convert() { cout<<”\n*************************************************\n” <<”This program converts the given infix expression\n” <<”in to postfix form” <<”\n*************************************************\n”; cout<<”Enter an infix expression ::\n”; cin>>infix; int l=strlen(infix); infix[l]=’)'; infix[l+1]=”; //Convertion starts top=1; stack[top]=’(‘; r=0; int x=-1; int i=0; char next=infix[i]; while(next!=”) { //Pop all the elements to outputin stack which have higher precedence while( input_p(next) < stack_p(stack[top]) ) { if(top<1) { cout<<”invalid expression ::stack error\n”; exit(0); } postfix[++x]=stack[top]; top–; r=r+rank(postfix[x]); if(r<1) { cout<<”Invalid expression ::r<1\n”; exit(0); } } if(input_p( next ) != stack_p( stack[top])) stack[++top]=next; else top–; i++; next=infix[i]; } postfix[++x]=”; if(r!=1 || top!=0) { cout<<”Invalid expression ::error in rank or stack\n”; exit(0); } cout<<”\n\nThe corresponding postfix expression is ::\n”; cout<<postfix<<endl; } int main() { expression obj; obj.convert(); return 0;
Urgent call: 03455242488. | Virtual University Assignments
Virtual University GDBs | Virtual University Papers | Vu Projects | Vu Handouts
About Expert
i guess this solution is good for students i have not found any comments.
Urgent call: 03455242488. | Virtual University Assignments
Virtual University GDBs | Virtual University Papers | Vu Projects | Vu Handouts
About Expert
there is no stake information and compile error
it is just for idea dear.
03009520262
Rabeel Website
There are currently 1 users browsing this thread. (0 members and 1 guests)