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# C# Basics (Retired) Perform Order of Operations

I don't understand the modulus operator. how do you perform this on a calculator? how are you getting the answers?

I don't understand the modulus operator. how do you perform this on a calculator? how are you getting the answers?

2 Answers

joelearner
joelearner
50,013 Points

Hi Joe,

The modulus is the remainder from a division operation. So if you have 15/5, you will get 3 and no remainder. The modulus is 0 here. Or if you have 18/4, you will get 4 and a remainder of 2. The modulus here is 2.

For example, if you had this: 5 * 2 + 9 % 4 + 8 / 4 Then you have 5 * 2 = 10, 9 % 4 = 1, 8 / 4 = 2 or 10 + 1 + 2 and your answer will be 13.

Cheers!

thank you! I also discovered that if you're doing this on a calculator it will give you a decimal. to convert to the remainder, your multiply the decimal to the divisor. Thanks!

Allan Clark
Allan Clark
10,808 Points

If joelearner provided helpful information and answered your question please take the time to upvote his answer and select as 'Best Answer', it will mark this question as closed and give him some swag points for his time :)

Happy Coding!