Modulus operator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Modulus operator

what does % do?

22nd Aug 2017, 4:37 PM
Yo Soy Groot!
13 Answers
22nd Aug 2017, 4:56 PM
AL.The.Flame!
AL.The.Flame! - avatar
+ 5
It's return the reminder of two number. 5%3 answer will be 2
22nd Aug 2017, 4:39 PM
Naila Rubab
Naila Rubab - avatar
+ 5
Yes that's right @Moddedgear
22nd Aug 2017, 4:44 PM
Naila Rubab
Naila Rubab - avatar
+ 4
the modulus operator returns the remainder
22nd Aug 2017, 4:38 PM
Styxincewa
Styxincewa - avatar
+ 4
35 % 5 would return 3 as remainder
22nd Aug 2017, 4:39 PM
Styxincewa
Styxincewa - avatar
+ 4
@Moddedgear Wrong 35%5 will return 0 as reminder.
22nd Aug 2017, 4:42 PM
Naila Rubab
Naila Rubab - avatar
+ 4
so if I had 52 % 7 the remainder would be 3?
22nd Aug 2017, 4:50 PM
Yo Soy Groot!
+ 4
% The modulus operator returns the remainder
22nd Aug 2017, 4:55 PM
Kartikey Sahu
Kartikey Sahu - avatar
+ 3
yeah I noticed that it would have to be 38 % 5 for remainder 3
22nd Aug 2017, 4:43 PM
Styxincewa
Styxincewa - avatar
+ 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
22nd Aug 2017, 4:46 PM
Styxincewa
Styxincewa - avatar
+ 3
yes!
22nd Aug 2017, 4:51 PM
Styxincewa
Styxincewa - avatar
+ 2
I appreciate all your help :) in think I understand how to use that operator now
22nd Aug 2017, 4:53 PM
Yo Soy Groot!
+ 1
what is the modulus operator for?
22nd Aug 2017, 4:37 PM
Yo Soy Groot!