Postfix evaluation · Compiler

Postfix evaluation

Evaluate a postfix expression. Each binary operator combines the two most recent available values. The older value is the left operand. Make the result available to later operators. Integer division truncates toward zero.

Input
One line with 1 to 99 space-separated tokens forming a valid postfix expression. Each token is a decimal integer from -1000 to 1000 or one of +, -, *, /. Every operation has a result between -1000000 and 1000000 and every divisor is nonzero.
Output
Print the final integer.

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

Loading your exercise draft…