INFIX TO PREFIX
Infix expression Prefix expression Explanation
A+B +AB The operator +
moves before its two operands, A and B.
A+B*C +A*BC Multiplication (*) has a higher
precedence than addition (+). The * is
applied to B and C first, so *BC is formed. The + then applies to A
and the result of *BC to form +A*BC.
(A + B) * (C + D) *+AB+CD The innermost parentheses are
converted first. (A + B) becomes +AB
and (C + D) becomes +CD. The final operation, *, is then moved
to the front to combine the results.
A*B+C*D +*AB*CD Both * operations have higher
precedence than +. They are
converted first (*AB and *CD). The + is then placed at the
beginning.
A+B+C ++ABC Because + is left-associative, (A + B) is
evaluated first, becoming
+AB. The expression then becomes (+AB) + C, which is Converted
to ++ABC.
A^B^C ^A^BC The exponentiation operator ^ is right-
associative. This means A