Whats is the mathematics operation of this? Is a division or whats.... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Whats is the mathematics operation of this? Is a division or whats....

int x=7; x= x%2;

14th Jun 2017, 3:31 AM
Zamir José Suazo Gómez
Zamir José Suazo Gómez - avatar
3 Answers
14th Jun 2017, 3:33 AM
jay
jay - avatar
+ 3
it gives the remainder for example 5%3=2 6%3=0 the answer for a%b ranges from 0 to b-1
14th Jun 2017, 3:38 AM
vivek_reddy
vivek_reddy - avatar
+ 3
It is modulo operator. 7%2 it divides 7 by 2 and returns the remainder, so 7/2= 3 and remainder 1 or 7= (3*2) +1 7%2 = 1
14th Jun 2017, 3:42 AM
Da' BO$
Da' BO$ - avatar