Infix evaluation · Compiler

Infix evaluation

Evaluate an arithmetic expression with binary operators and parentheses. Within each group, * and / take precedence over + and -. Evaluate operators of equal precedence from left to right. Integer division truncates toward zero.

Input
One line with 1 to 99 space-separated tokens forming a valid infix expression. Tokens are decimal integers from 0 to 1000, operators +, -, *, /, or parentheses ( and ). All operators have two operands. Every operation has a result between -1000000 and 1000000 and every divisor is nonzero.
Output
Print the value of the entire expression as an integer.

Compiler Explorer runs your code when you run or check it.

Loading your exercise draft…