Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
Operator to obtain the remainder from an integer division.
const int three = 7 % 4; //3 is the remainder of 7 divided by 4 |
operator% can often be found in prime determination (in the tool PrimeExpert for example).
The code below shows how to determine if a value is odd or even.
if (x%2==0) |
The STL functor encapsulating operator% is called std::modulus.
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.