+ 1

int x = 25 % 7; cout << x; /// why the output is 4 ??

Help me please....

26th Mar 2017, 1:51 AM
Gilang Rizki
Gilang Rizki - avatar
2 odpowiedzi
+ 9
Hi % is the modulus operator, which returns the remainder of the Euclidean division For example : if a=q*b+r ; for a and b are integers a%b will return r (the remainder of the division of a by b) -----Now, For your question: x=25 % 7 We know that 25 = 3 * 7 + 4 (Euclidean division of 25 by 7) with 4 as remainder So x=4 That's why the output is 4
26th Mar 2017, 2:00 AM
MizoPro
MizoPro - avatar
+ 1
owh okayy,thank you very much @ MIZO PRO
26th Mar 2017, 2:03 AM
Gilang Rizki
Gilang Rizki - avatar