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 trialkurtan bert
Courses Plus Student 213 PointsC# Basics match questions. Can't understand what you do with the % in the math question.
8 * 7 + 8 % 5 + 6 / 2 = ????
3 Answers
Steven Parker
231,269 PointsThat's the modulus operator.
Also called "modulo" or "remainder", the modulus operator performs a division operation but instead of returning the result it returns the remainder. For example, 12 % 7 = 5
because if you divide 12 by 7 the result is 1 but you have 5 left over. For expression evaluation, it has the same precedence as the multiply and divide operators.
Jennifer Nordell
Treehouse TeacherHi there! The % sign is used as the modulus/modulo operator. This operator returns the remainder of the division of the 2 numbers. For example, in this case, the 8 % 5 would return a 3. This is because 8 is divisible by 5 with a remainder of 3. Eight divided by five is equal to 1 and 3/5. The three here is the remainder.
Hope this helps!
kurtan bert
Courses Plus Student 213 PointsOk thanks I understand now