#C10368. Arithmetic Expression Evaluator
Arithmetic Expression Evaluator
Arithmetic Expression Evaluator
You are given an arithmetic expression as a string. The expression may contain integers or decimal numbers and the operators \(+, -, \times, \div\) along with parentheses to explicitly denote the order of operations.
Your task is to evaluate the expression and output its result. If the expression is invalid (for example, due to syntactical errors or a division by zero), you must output an appropriate error message exactly as specified below.
Examples:
- Input:
2 + 3
; Output:5
- Input:
(2 + 3) * (4 - 2)
; Output:10
inputFormat
The input consists of a single line (read from stdin) containing an arithmetic expression. The expression can include integers, decimal numbers, the operators (+, -, *, /) (or their symbolic equivalents (\times, \div)), and parentheses.
outputFormat
Output to stdout the result of evaluating the expression. If an error occurs during evaluation (e.g., syntax error or division by zero), output exactly the error message as described in the examples.## sample
2 + 3
5