Infix notation facts for kids
![]() |
Prefix notation |
Infix notation |
Postfix notation |
Infix notation is a common way to write math problems and logic puzzles. It's how you usually see numbers and symbols in a math book. In this style, the action symbol (called an operator) sits between the things it's working on (called operands). For example, in "2 + 2", the plus sign is the operator, and the two numbers are the operands.
Even though computers find it a bit tricky to understand, many programming languages use infix notation. This is because it's very familiar to people. Other ways to write math problems include prefix notation (where the operator comes first, like + 2 2) or postfix notation (where the operator comes last, like 2 2 +).
In infix notation, you often need to use parentheses (like these: ( )) to show which parts of the problem should be solved first. If there are no parentheses, special rules called the order of operations tell you what to do. These rules make sure everyone gets the same answer to a math problem.
Contents
What is Infix Notation?
Infix notation is the way we usually write math problems. Think of it like a sandwich: the operator (like +, -, *, /) is the filling, and the numbers or variables (operands) are the bread on either side. This makes it easy for us to read and understand.
For example, if you see "5 * 3", you know you need to multiply 5 by 3. The multiplication sign is right in the middle. This is different from some other ways computers might see the same problem.
How Infix Notation Works
When you write a math problem using infix notation, you place the operator right between the two numbers or values it connects. This is very natural for humans. It matches how we speak about math.
Let's look at some examples:
- Addition: 10 + 5 (adds 10 and 5)
- Subtraction: 20 - 7 (subtracts 7 from 20)
- Multiplication: 4 * 6 (multiplies 4 by 6)
- Division: 15 / 3 (divides 15 by 3)
These are all examples of infix notation. The operator is always in the middle.
The Importance of Parentheses
Sometimes, a math problem has many operators. For example, "2 + 3 * 4". If you just read it from left to right, you might think "2 + 3 = 5", then "5 * 4 = 20". But that's not always right!
This is where parentheses come in handy. They tell you exactly what to do first.
- If you write "(2 + 3) * 4", it means "add 2 and 3 first (which is 5), then multiply by 4 (which is 20)".
- If you write "2 + (3 * 4)", it means "multiply 3 and 4 first (which is 12), then add 2 (which is 14)".
Without parentheses, we rely on the order of operations (like PEMDAS or BODMAS) to solve problems correctly. But parentheses always override these rules, making the order clear.
Infix Notation and Computers
While infix notation is easy for people, it's a bit harder for computers to "read" directly. Computers often prefer prefix notation or postfix notation. These other notations don't need parentheses to show the order of operations.
However, because infix notation is so common, many programming languages are designed to understand it. They use special rules and algorithms (like the Shunting yard algorithm) to change infix notation into a format they can easily process. This allows programmers to write code that looks like regular math.
Want to Learn More?
- postfix notation, also known as Reverse Polish notation
- prefix notation, also known as Polish notation
- Shunting yard algorithm, a method used to change infix notation into other forms that computers can understand.