// Prog: divmod.cpp // demonstrates the law of integer division with // remainder: a / b * b + a % b == a, for b != 0 #include #include int main () { // input a and b std::cout << "Dividend a =? "; int a; std::cin >> a; std::cout << "Divisor b =? "; int b; std::cin >> b; assert (b != 0); // check the law for a and b assert (a / b * b + a % b == a); // print the law for a and b std::cout << a << " / " << b << " * " << b << " + " << a % b << " == " << a << "\n"; return 0; }