EZ Programing Demos

Slow motion, step by step, animated demonstrations of basic computer programing techniques

Links to topics:

Current topic:

Precedence without parentheses

The arithmetic operations of addition, subtraction, multiplication, and division have an order. When an arithemetic expression has more than one operation, and it has no parentheses, then there are rules that state which operations go first and which operations go next. These rules are called the rules of precedence. To see this situation we will present a simple arithmetic expression:

    2 + 3 * 4

One might read this, "Two plus three times four."

To correctly calculate the result, you need to know the rules of precedence. They are:

  • First, do all multiplications and divisions, left to right.
  • Second, do all additions and subtractions, left to right.

So, for the above example we would first calculate three times four (since multiplications happen first) and get twelve. Then we would add two and twelve (since additions happen second) and get a final result of fourteen:

    2 + 3 * 4 = 2 + 12 = 14



Use the programing demo below to experiment with how this precedence works. These rules of precedence are present in most common computer languages.

 Slow  Medium  Fast 
Click 'Run' to go.

Raising to a power is often called a math operation, and it would have the highest order of precedence, above even multiplication and division. In some languages, such as BASIC or those found on handheld calculators, raising to a power is notated with a caret or up arrow. So, 2 raised to the 3 power could look like this:


As it turns out, when combined with other operators or negative values, the above notation can be confusing. Some computer languages, such as C and Java, simply opt for considering raising to a power to work like a function call. So, 2 raised to the 3 power can look like this:

    pow(2, 3)


The flowchart for this demo looks like this:


Here is how this could appear in an imaginary computer language:

    print(2 + 3 * 4);


Suggested next article:

At EZ Math Movie

EZ Math Movie is a site that can help you experiment with and understand many topics in mathematics. Its main feature is an interactive animated (x, y) graph that you control with an actual programing language. There are many examples and tutorials, and EZ Math Movie is crossed referenced with both EZ Programing Demos and Zona Land Education.


Zona Land Education is a site with explanations and interactive diagrams covering many topics in physics and mathematics. Zona Land Education is cross referenced with EZ Math Movie, and it contains several animations that use EZ Math Movie's programing language.