0
what does it(%) mean?
I can't understand what its function is. Give me examples please
2 Answers
+ 4
% is a modulus operator, and it is used to return the remainer of a division.
For example:
5 % 2 = 1
10 % 5 = 0
30 % 7 = 2
A very common, and beginner way to use the modulus is to tell whether or not a number is even:
if (x % 2 == 0)
{
//even
}
else
{
//odd
}
+ 1
modulus operator ,used to get remainder in divison