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.
C# Basics match questions. Can't understand what you do with the % in the math question.
8 * 7 + 8 % 5 + 6 / 2 = ????
Steven Parker215,372 Points
That'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 NordellTreehouse Teacher
Hi 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!
Ok thanks I understand now