4.2: 📿 Using Multiple Arithmetic Operators

Topic

4.2: 📿 Using Multiple Arithmetic Operators

Topic Progress:

When using multiple operators in a single line of code, for example, 4+4*2, you have to be wary of which order you write them in. You may also need to use brackets in order to run the operators in the correct order. A simple acronym, BEDMAS, can help you understand what operators will act first in your line of code. BEDMAS stands for:

Brackets – Anything in brackets will be done first

Exponents – Don’t worry about this for the moment

Division and Multiplication – These two come before addition and subtraction, but when these two are put on the same line the operators just run from left to right

Addition and Subtraction – These operators come last, but like division and multiplication, when these two are put on the same line the operators just run from left to right.

To give an example:

Going left to right, some people may think that this program would print 16, as 4+4 is 8, and 8 x 2 is 16. However, from what we learned before we know this is false. Using BEDMAS, we know that the multiplication will act first, so the program will print 12, as 4 x 2 is 8, and 4 + 8 is 12.

Your task is to make the program print 16 using brackets, without changing the numbers.

@

Not recently active