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.
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,258 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,402 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!