+ 1

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

Help me please....

2 Answers

+ 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

+ 1

owh okayy,thank you very much @ MIZO PRO