#include <iostream>
int main() {
int dividend, divisor, quotient, remainder;
std::cout << "Enter dividend: ";
std::cin >> dividend;
std::cout << "Enter divisor: ";
std::cin >> divisor;
quotient = dividend / divisor;
remainder = dividend % divisor;
std::cout << "Quotient = " << quotient << std::endl;
std::cout << "Remainder = " << remainder;
return 0;
}
Enter dividend: 17
Enter divisor: 4
Quotient = 4
Remainder = 1
dividend
, divisor
, quotient
, and remainder
, which are all of type int
. std::cout
and std::cin
objects from the iostream
library. The >>
operator is used to input the user's numbers into the variables dividend
and divisor
./
and %
operators, respectively. quotient
variable, and the remainder
is stored in the remainder
variable. Finally, the program uses std::cout
to output messages that display the quotient and remainder to the console.