I have next code
int a,b,c;
b=1;
c=36;
a=b%c;
What does “%” operator mean?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is the modulo (or modulus) operator:
For example:
Sample output:
Note that the result of the
%operator is equal tox – (x / y) * yand that ifyis zero, aDivideByZeroExceptionis thrown.If
xandyare non-integer valuesx % yis computed asx – n * y, wherenis the largest possible integer that is less than or equal tox / y(more details in the C# 4.0 Specification in section 7.8.3 Remainder operator).For further details and examples you might want to have a look at the corresponding Wikipedia article: