I am new to programming . I knew that modulo operator gives remainder for example 7%2=1 but I didn't understand how 1%10= 1 . Can someone please explain it.
Asked
Active
Viewed 376 times
-6
-
If you have 1, you can take away 0 times 10. How much do you have left? – Cheatah Oct 31 '21 at 04:42
-
you are trying to say that we can write 1 as 10*0+1 where 1 is acting as a remainder. – PRIYANSHU KUMAR Oct 31 '21 at 04:55
-
Yes, that would be a way to put it. – Cheatah Oct 31 '21 at 05:05
-
C lacks a true _modulo_ operator. `%` is better thought of as the _remainder_ operator. [What's the difference between “mod” and “remainder”?](https://stackoverflow.com/a/20638659/2410359) – chux - Reinstate Monica Oct 31 '21 at 05:42
3 Answers
1
When the dividend
is smaller than the divisor
, then the dividend
itself is the remainder. means in your case 1%10
is 1
Points to remember regarding the '%' operator :
- When the dividend is greater than the divisor, it will give the remainder.
10 % 3 = 1
- When the dividend is smaller than the divisor, then the dividend itself is the remainder.
3 % 10 = 3

vegan_meat
- 878
- 4
- 10
-
you are trying to say that we can write 1 as 10*0+1 where 1 is acting as a remainder. – PRIYANSHU KUMAR Oct 31 '21 at 04:56
-
0
1 % 10 = 10 ) 1 ( 0
-0
------
Remainder = 1
-
ya I'm trying to say this that we can write 1 as 10*0+1 where 1 act as remainder – PRIYANSHU KUMAR Oct 31 '21 at 06:29
-
0
Taking your example, when you say that 7%2 =1, it means the remainder is 1 and the quotient would be 3.
Similarly for 1%10,when we divide 1 by 10, the quotient is 0 but the remainder comes out to be 1.
Therefore 1%10=1.

saurabh suchak
- 1
- 1