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#

Josh Gallacher
PLUS
Josh Gallacher
Courses Plus Student 3,325 Points

Math (C# Beginner)

So, I'm struggling with a quiz question:

8 * 7 + 8 % 5 + 6 / 2 =

As I understand the lesson, the multiplication, modulus and division take first precedence so how I've been working it out is this:

8 x 7 = 56 8 / 5 = 1.6 making the modulus 6 6 / 2 = 3

Then moving on to the second precedence addition creating this sum:

56 + 6 + 3 = 65

But, this is the incorrect answer according to the quiz. If someone could point out what I'm getting wrong without giving away the answer, I'd really appreciate it. Thanks :)

2 Answers

Hi! , How ur doing?

You misunderstood what a % is lets break it down: u go from left to right in this example >>> 8 * 7 + 8 % 5 + 6 / 2 =

1.>>> 8*7 = 56 2.>>8%5 = 3 >> the answer is 3 because when u use % u get the remainder which is 3 because 5 fits 8 only 1 time. 3.>>6/2 = 3

the answer is 56 + 3 + 3 = 62

i hope u understand it now.