Why dis output come 2???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
10th Jun 2018, 3:55 AM
Harsh Agrawal
Harsh Agrawal - avatar
4 Answers
+ 13
In case you didn't know, "%" is the modulo operator, which means that it takes the remainder of integer division. 2%7 is the remainder when 2 is divided by 7 2/7=0 R**2** This 2 is the output.
10th Jun 2018, 4:03 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 8
modulus operator returns remainder so when a%7 = 2%7 (where a=2) the remainder is became 2 because integer division 7 divide 2 return 0 so remainder 2 is return if you do 7%a then 7%2=1 so 1 will be returned
10th Jun 2018, 4:04 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 4
if numerator < denominator modulus operation returns numerator.
10th Jun 2018, 4:16 AM
💫...MayurK Koli...💫
💫...MayurK Koli...💫 - avatar
0
thnxxxxx all of u!!!!!!
10th Jun 2018, 4:10 AM
Harsh Agrawal
Harsh Agrawal - avatar