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

% operator

Hi, friends! Can any1 tell me the result of "2%4"? And explane how this stuff works. Thank u Mb, for example some expressions: 2%5 =? ; 3%10=?

8th Jan 2020, 5:46 PM
Айнур Мурзин
Айнур Мурзин - avatar
7 Answers
+ 4
% is an “operator” that ussually represents modulus. Modulus is basically just a fancy term for remainder. So 3%2 will be 1 4%2 will be 0 5%3 will be 2 etc... Edit: When the number is being “modulused” by a number bigger than it than it is just that number. Ex: 1%100 is 1 50%100 is 50 2%5 is 2 etc...
8th Jan 2020, 5:50 PM
Pie
Pie - avatar
+ 3
Here the result from your question: 2%4 result is 2 2%5 result is 2 3%10 result is 3
8th Jan 2020, 6:34 PM
Lothar
Lothar - avatar
+ 2
Coder Kitten Half cookie each...😂 Sorry I couldn't help it...
8th Jan 2020, 7:02 PM
Mihai Apostol
Mihai Apostol - avatar
+ 1
I understand what will be 3%2, 4%2 or 5%3 But I cant understand expressions when first number higher than second, for example, 2%4, 2%5,3%10 Or it is the same result?
8th Jan 2020, 6:00 PM
Айнур Мурзин
Айнур Мурзин - avatar
+ 1
Результатом є лише остаток від ділення - незалежно від того який результат самого діження...
8th Jan 2020, 7:06 PM
Володимир Лазар
Володимир Лазар - avatar
+ 1
Thank you, guys, now I think know how it works ;)
9th Jan 2020, 3:40 AM
Айнур Мурзин
Айнур Мурзин - avatar
0
5%2=1 5/2=2
10th Jan 2020, 5:16 PM
Than Aung
Than Aung - avatar