Here, I provide a C++ implementation of a console – based calculator. Basically, it reads in infix arithmetic expressions and produces the result of their evaluation.

I made the simplifying assumption that tokens in the input expression are separated by spaces in order to simplify tokenization. The evaluation of expressions is done with two stacks, one for operands and the other for operators. The program combines the algorithms for infix-to-postfix conversion and postfix evaluation, eliminates the production of intermediate postfix expression and requires just one scan of the input infix expression.

Take a look at the C++ implementation.

Try your hand at problem ARTHEVAL that uses this idea.

28.635308
77.224960

### Like this:

Like Loading...

*Related*