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

Misha Karas
Misha Karas
5,636 Points

Modules #C basics

So i am doing the #C basic track and so far so good, but now i have a math question but i cand find a calculator what also does modules. So i want to know what the awnser is on this question and maybe also the question after this if they also contain modules. 8 * 7 + 8 % 5 + 6 / 2 = .........

2 Answers

Steven Parker
Steven Parker
231,248 Points

:point_right: You can also think of % as the remainder operator.

So for example, to calculate 8 % 5 on a "four-banger", you would first divide 8 by 5 — that gets you 1.6. Then, multiply just the fractional part (.6) by 5 — which gives you your answer (3).

But it's hard to imagine not having access to a calculator that would do this for you. If you use a windows computer, just bring up the on-screen calculator, be sure it is in scientific or programmer mode, and then use the MOD button. In this case, 8 MOD 5 will get you 3.

:information_source: The word for this operation is modulus. The term "modules" is also commonly used in programming, but has a different meaning.

Misha Karas
Misha Karas
5,636 Points

Thanks a lot! And thanks for the tip with modulus and modules :D