I not understand with % | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I not understand with %

17th Apr 2016, 3:29 AM
alexander yogatama
alexander yogatama - avatar
5 Answers
+ 2
is the remainder of the operation, for example 100%10 results 0 because 100/10 = 10 and there is not remainder, another example is 5%2 the result is 1 because 5/2 = 2 and the remainder is 1
21st Apr 2016, 3:54 AM
Hector ortega berumen
Hector ortega berumen - avatar
+ 2
Modulus is remainder value after the closest division. In case of 38 modulus 5. The closest we can go is 35(5 times 7). The remaining number is modulus. Three in this case. 38-35 equals 3. Hope this helps.
14th Jun 2016, 11:41 PM
Utpal Kumar
Utpal Kumar - avatar
+ 1
The modulus operator is very different from division. it does divide, but that number is discarded, whatever is left is printed. in the example of 25%7 we get this; 25/7 does not give a whole number, 21/7 is the closest since we cant increase the starting value of 25. this results in 3, but is discarded. 25-21 is all that matters here, and the answer to that is 4. this can be used to calculate for example; the number of leftover days in a year when you divide the days in a year (365) by the number of weeks in a year (52). 365%52 becomes 364/52 to make the result a whole number. 365-364=1, in this case 1 is printed. Hope this helps:)
20th Jun 2016, 1:17 AM
Utpal Kumar
Utpal Kumar - avatar
0
% is mod. if 100%10 then ans o bcz reminder is ntg .
29th Jun 2016, 10:28 AM
swati sakhvala
0
jerk it man
14th Oct 2016, 2:39 PM
sathya Narayan.R
sathya Narayan.R - avatar