I have a string which has this:
((12+41)*30)
here 12, 41 and 30 are all characters. How do I do arithmetic operations on them ?
Also when I have a number 20 how can I get a string which reads 20?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In order to calculate expressions like that you need create a tree of the tokens 12, +, 41, 30
this can be done for instance by converting your infix expression to a postfix expression, by doing so the correct operator precedence can be set. Then you go through the tree using a stack to evaluate the expression.