Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,258 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.