Need to write a program that evaluates a postfix expression which is input by the user and then displays the answer.
2 views (last 30 days)
Show older comments
For example, if the user inputs 493*+ then the program should evaluate this postfix expression and display the answer. The user input can vary and the total number of characters may also vary. So, this should also be taken into consideration while writing the program. Thanks!
Answers (1)
Bjorn Gustavsson
on 2 Feb 2017
If you want us to do your assignments you might have a better chance if you explicitly ask us to. What have you done so far?
Small tip: if current character (token rather!) is a number put it on a stack, if it is an operator take contents of stack and perform operation on those.
HTH
2 Comments
Walter Roberson
on 7 Feb 2017
current_position = 5
current_character = input_string(current_position)
if current_character == '0'
... do something appropriate
elseif current_character == '2'
.... do something appropriate
elseif current_character == '{'
... do something appropriate
elseif current_character == '⁞'
... do something appropriate
end
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!