Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Basics (Retired) Perform Order of Operations

Diego Souza de Andrade
Diego Souza de Andrade
1,807 Points

I think something is wrong

Hi, I have calculated some answers and none of them are right, there is a chance, even if small, that the quiz is broken or something? haha

If the problem are my calculations, can somebody help me? thanks!

1 Answer

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

the quiz is ok, it's not broken. when you see something like 4 * 33 % 7 + (4+5), the first thing to do is anything in parens (), so 4+5 is 9, then the proper order is that multiplication, division and modulo are of highest order, and thus are evaluated first, left to right. addition and subtraction are of lower order, and are done after *, / and %. so after we do the addition in the parens, what is left? a mult, a mod and a plus. so you would do 4 * 33, that's 132, then you would take 132 mod 7, which is 6, then you would add that to the 9 you have from the parens, and the result is 15. here are some other examples: 4 / 2 % 13 * 5 + 8 = 18. 43 - 12 * 2 + 17 = 36.