Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to calculate% of C language?
How to calculate% of C language?
In C/C++, "%"is a remainder operator, which applies to unsigned integer variables. For unsigned integer variables m and n, then

For example, the result of m%n is 0 ~ n- 1.

105%5 = 0

12%5 = 2

3%2 = 1

26%7 = 5

Algorithm: subtract n from m, if the difference is less than n, then this difference is the result of remainder, otherwise continue to subtract n from the obtained difference until the difference is less than n, and the final difference is the result of remainder.