+ 1
[DUPLICATE] Can someone explain the modulus operator and its working ?
need help understanding.
6 Answers
+ 12
Check the following posts first..If you still don't understand, feel free to ask me
https://www.sololearn.com/discuss/270744/?ref=app
https://www.sololearn.com/discuss/408503/?ref=app
+ 6
Modulus operator returns the reminder after dividing the first number with the second one.
If the first number is smaller than the second, then the quotient will be zero while the remainder will be the first number itself.
If both the numbers are perfectly divisible, remainder will be zero.
+ 5
Modulus operators:::::: % it returns the reminder
Eg. 3%2=1.. because 1*2 = 2 ...reminder will be 1 which is returned by the modulo operator..
Working:::: Usually it is used for retrieving the last no...by using %with 10, 100, ...
Eg. 123 % 10 = 3.....because
12
_____
10 |123
120
-------
003
------- thus the last no
of 123 is retrieved
+ 2
If we divide 1.25 by 2 than, we can write:
1.25= .5*2(here .5*2=1)+.25 (here .25 is remainder)
hence,
1.25 divided by .5, quotient is 2 and .25 isn't divided by .5 so it is remainder.
above term is expressed by modulus sign (%),where % shows only remainder,not shows quotient.
it is expressed by
5%2 = 1
11%4 = 3
5%3 = 2
3%5 = 3
6%5 = 1
12%7 = 5
2%2 = 0
1.25%.5 = .25
+ 1
â5 / 5 is 1 it gives the quotient
but
â 5%5 is 0 it gives the remainder
â 10/3 ==> 3 (quotient)
â 10%3 ==> 1 (remainder)
0
it is used for returning the remainder. for example if you divide 15 by 2 then remainder is 1. we use percentage sign % for returning remainder