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!
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
Order of Operation are not working
I have run through the problem many times and even in the console, but the c# oder of ops gives me the wrong answer. This may be a bug or I am just completely wrong. Please Help!
james southFront End Web Development Techdegree Graduate 33,271 Points
the quiz does not have a bug. left to right (1) anything in parens (), then (2) multiplication, division and modulo are of the same priority, then (3) addition and subtraction are of the same priority. so do operation in parens, then look for mult, div and mod, do those left to right, then look for add and sub, do those left to right.
I need help on #1, but I will still need help on others swell.
Seth Kroger56,412 Points
The first one is 8 * 7 + 8 % 5 + 6 / 2 = ???. There are no parentheses so we start with *, /, and % left to right.
8 * 7 + 8 % 5 + 6 / 2 -> 56+ 8 % 5 + 6 / 2
56 + 8 % 5 + 6 / 2 -> 56 + 3 + 6 / 2
56 + 3 + 6 / 2 -> 56 + 3 + 3
Then the addition:
56 + 3 + 3 = 62
Thank you very much that helps a lot!