Write a C++ program to find the quotient and remainder of a given dividend and divisor.
The division operator / is computes the quotient (either between float or integer variables).
The modulus operator % computes the remainder when one integer is divided by another (modulus operator cannot be used for floating-type variables).
C++ Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <iostream> using namespace std; int main() { int divisor, dividend, quotient, remainder; cout << "Enter dividend: "; cin >> dividend; cout << "Enter divisor: "; cin >> divisor; quotient = dividend / divisor; remainder = dividend % divisor; cout << "Quotient = " << quotient << endl; cout << "Remainder = " << remainder; return 0; } |
Output: