I did not understand modulus operator. Please explain | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

I did not understand modulus operator. Please explain

I couldn't understand how the remainder is left behind and why % sign is used

16th Mar 2017, 11:11 AM
Alina Palchoudhury
Alina Palchoudhury - avatar
3 Réponses
0
Modulus is kinda like division but insted of giving you have many time something can be divided, it gives you "what is left" (the remainder) after the division. 4/2 = 2 4%2 = 0 4/3 = 1,333333...... 4%3 = 1 15/7 = 2,1428......... 15%7 = 1
16th Mar 2017, 12:37 PM
Michael Sall Timm
Michael Sall Timm - avatar
0
How come 4%2=0 What % represent ??
19th Mar 2017, 6:19 AM
Aziz LA
Aziz LA - avatar
0
% is the "modulus" operator, just like + - / * Are operators, and the modulus calculation result is the the "remainder" it works just like division. but results in what is left aften the division 5/2 = 2.xxx 5%2 = 1 6/2 = 3 6%2 = 0 4/2 = 2 4%2 = 0
19th Mar 2017, 7:34 AM
Michael Sall Timm
Michael Sall Timm - avatar