0
Modulus operator %
somebody please explain how a % operator in c++ works suppose, int x = 6%4 ; how is value of x evaluated?
3 Respuestas
+ 1
modulus is the remainder of the 2 numbers.
when you divide 6 by 4, you'll get 1 remainder 2. so the answer of 6%4 is 2.
6/3 = 2 remainder 0
6%3 = 0
6/5 = 1 remainder 1
6%5 = 1
7/5 = 1 remainder 2
7%5 = 2
+ 1
See my "% Modulus explained" code to understand in a way, you may have learnt at school
https://code.sololearn.com/c2fRl6x893E7/?ref=app
0
the answer is the remainder of the equation not the normal answer