// 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); // compute result int div = a / b; int mod = a % b; // check result assert (div * b + mod == a); return 0; }