[Solved] Calc many value with many arithmetic operators c++ [closed]


Writing a calculator is not an easy task, as there is more involved:

  1. Operator Precedence
  2. Grouping
  3. Evaluating of expressions

Operator Precedence
Operator precedence is the grouping of operations, such as performing all multiplication and division before addition and subtraction. A calculator program should handle precedence without parenthesis (grouping).

Grouping
A more advanced calculator will allow grouping of expressions, using parenthesis. The calculator should be able to evaluate the inner most expression and work outward.

Evaluating of Expressions
This means allowing more than 1 digit numbers, and whitespace between numbers and symbols. Also, once the expression is parsed, it needs to be evaluated. The calculator should call the appropriate functions based on the operation (specified by the User).

I suggest you allow the User to enter an expression, and your program read it in as a string. Your program will then parse the string, then evaluate the expression(s).

Search the web and StackOverflow for “c++ calculator” for examples.

4

solved Calc many value with many arithmetic operators c++ [closed]