hello Friends, I'm making a program and facing a problem in code, i want to input an equation , it have characters and integers, mix input in single line .so characters(/,*,-,+) store in character array and integer(1,2,5..etc) stores in integer array from equation,how can i do this step..???? input: 4+4*6/6 output: 9 just little guide or hint me i want to make this program myself...... my English is weak but i hope you'll understand my problem..
I think I understand. You're trying to build a calculator? If you take the input into a character array or string, you can step through it using a while loop. Check the ASCII value to see if the current character is a special character or a number, then move to its respective array. Once you've done this, you'll need to use a switch statement to actually perform the operations on the numbers. Also, is the answer to your example problem supposed to be 8, not 9?
As long as I understand you are trying to write Reverse Polish Notation Calculator. Here is a description of the algorithm: http://en.wikipedia.org/wiki/Reverse_Polish_notation And C++ source code: http://www.uow.edu.au/~lukes/TEXTBOOK/notes-cpp/examples/rpn/rpn.html C# source code: http://www.codeproject.com/KB/cs/Reverse_Polish_Notation.aspx