+ 2
how the modulous operator work i.e '%' ?
3 odpowiedzi
+ 3
x=a%b is
x=a-(largest number that is divsible by b but less than or equal to a)
example
100%3
=100-99
=1
13%7
=13-7
=6
15%5
=0
15%0
=0
also keep in mind that we are talking about positive integers.
0
the % divides a number and gives you the remainder. Example: x = 15 % 6; first it will do 15/6 which is 2 and the remainder is 3. 3 gets assigned to x there for x is 3.
0
'%' operator gives u da remainder wen u divide any two nos. a and b as a/b