Home > Enterprise >  Modulo operator in c
Modulo operator in c

Time:10-31

I am new to programming . I knew that modulo operator gives remainder for example 7%2=1 but I didn't understand how 1= 1 . Can someone please explain it.

CodePudding user response:

When the dividend is smaller than the divisor, then the dividend itself is the remainder. means in your case 1 is 1

Points to remember regarding the '%' operator :

  1. When the dividend is greater than the divisor, it will give the remainder.

10 % 3 = 1

  1. When the dividend is smaller than the divisor, then the dividend itself is the remainder.

3 % 10 = 3

CodePudding user response:

1 % 10 =    10 ) 1 ( 0
                -0
               ------
     Remainder = 1

CodePudding user response:

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,when we divide 1 by 10, the quotient is 0 but the remainder comes out to be 1.

Therefore 1=1.

  • Related