+ 2
In what situation would we want to use modulus (%)
7 Réponses
+ 9
1.If we want to know the remainder of the quotient.
2. If we want to check whether the number is even or odd.
+ 2
we use the when we have a need to find the remainder
+ 2
When you.do for examle number%10 it will give you the most right char. (Right side)
It is usefull for bools, if, while. You will see in future
+ 1
To find even/odd numbers, right most digits of a collection of nums , left most digits of a collection nums. And many more cases!
+ 1
As a working programmer I need it every day, for example if you use flat array of n×m elements instead of two dimensional or in many other fields
+ 1
It's very important for sorting out Tables. Look up table and hashing.
+ 1
Useful whenever you need to know the reminder of an integer division. eg to find out if a number is a multiple of another one. or add up the digits of a large number.