Modulus operator | SoloLearn: Learn to code for FREE!

+3

Modulus operator

what does % do?

8/22/2017 4:37:05 PM

Yo Soy Groot!

13 Answers

New Answer

+6

I hope it will help u :) https://www.sololearn.com/discuss/647552/?ref=app

+5

It's return the reminder of two number. 5%3 answer will be 2

+5

Yes that's right @Moddedgear

+4

the modulus operator returns the remainder

+4

35 % 5 would return 3 as remainder

+4

@Moddedgear Wrong 35%5 will return 0 as reminder.

+4

so if I had 52 % 7 the remainder would be 3?

+4

% The modulus operator returns the remainder

+3

yeah I noticed that it would have to be 38 % 5 for remainder 3

+3

an easy way of working it out is adding the second number to the first number as many times as you can 38 % 5 = 3 second number is 5 so 5+5=10 until your at 5+5+5+5+5+5+5=35 now you can't add 5 again and the number your left with is the remainder, that will be 3

+3

+2

I appreciate all your help :) in think I understand how to use that operator now

+1

what is the modulus operator for?