| | |
Help pplz. . convert infix to postfix. .
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2007
Posts: 7
Reputation:
Solved Threads: 1
Hi. . can any one help me in converting infix to postfix. . i do not know what is wrong in my code. . help!!!plz
C++ Syntax (Toggle Plain Text)
#include<iostream> #include<string> #include<conio.h> #include<stdio.h> using namespace std; void main() { char stack[10]; char input[10]; char output[10]; char plusminus,multdiv; int a; cout<<"\tInput an infix expression:"; gets(input); int i; i=strlen(input); cout<<strlen(input); for(a=0;a<=i;a++){ if(input[a]>='a'&&input[a]<='z'){ output[a]=input[a]; } else if(input[a]=='+'||input[a]=='-'){ plusminus=input[a]; } else if(input[a]=='*'||input[a]=='/'){ multdiv=input[a]; } if(input[a]==plusminus){ stack[a]=input[a]; if(stack[a]==plusminus&&stack[a+1]==plusminus){ output[a]=stack[a]; } } else if(input[a]==multdiv){ stack[a]=input[a]; if(stack[a]==multdiv&&stack[a+1]==multdiv){ output[a]=stack[a]; } } } cout<<"\tPostfix Expression :"<<output<<"\n"; }
Last edited by Narue; May 9th, 2007 at 10:05 am. Reason: Added code tags
Yes void main, gets (you're using c++ so no need for them anyway) conio.h all wrong and/or unnecessary.
http://www.daniweb.com/code/snippet599.html
See there for ideas.
http://www.daniweb.com/code/snippet599.html
See there for ideas.
Last edited by iamthwee; May 9th, 2007 at 2:27 pm.
*Voted best profile in the world*
•
•
•
•
Hi. . can any one help me in converting infix to postfix. . i do not know what is wrong in my code. . help!!!plz
And check the following links to see what is wrong with gets() and void main()
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
Friends plz help me to write simple c++ program just to convert infix expression to postfix expression using stacks, i don't know abt C++ too much, just write a simple c++ program, i have to submit my assignment, mail me at: SNIP
Last edited by happygeek; Oct 19th, 2009 at 6:42 pm. Reason: email snipped
![]() |
Similar Threads
- Java Simple calc (Java)
- help with a infix to postfix program (C++)
- Prefix to Infix help please (C)
- Please AnyBody Can Help Me To Build Assembly Code Infix To Postfix It So Hard T_T (Assembly)
- Any Boolean Expression to Sum of Minterms (C++)
Other Threads in the C++ Forum
- Previous Thread: multiple forms
- Next Thread: C-String reverse
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






