C++ Program to Find Quotient and Remainder

In this tutorial, we will write a C++ program to find the quotient and remainder of a given dividend and divisor.

The program asked the user to enter the numbers (divisor and dividend). And to compute and find the quotient and remainder, we will use the division(/) and modulus(%) operators.


C++ Program to Find Quotient and Remainder

#include <iostream>
using namespace std;

int main()
{    
   int denominator, numerator, quotient, remainder;

   cout << "Enter numerator: ";
   cin >> numerator;

   cout << "Enter denominator: ";
   cin >> denominator;

   quotient = numerator / denominator;
   remainder = numerator % denominator;

   cout << "\nQuotient: " << quotient << endl;
   cout << "Remainder: " << remainder;

   return 0;
}

Output:

Enter numerator: 20
Enter denominator: 10

Quotient: 2
Remainder: 0

Enter numerator: 15
Enter denominator: 4

Quotient: 3
Remainder: 3