C++ Program to Find Quotient and Remainder

C++ Programs

Problem: Write a C++ program to find the quotient and remainder of the given dividend and divisor.



Dividend = 13
Divisor = 5


Quotient = 2
Remainder = 3

The division / operator calculates the quotient by dividing the dividend by divisor, whereas the modulus % operator computes the remainder of the division.

We can use these operators in C++ to compute quotient and remainder as follows:

#include <iostream>
using namespace std;

int main() {
    int divisor, dividend, quotient, remainder;
    cout << "Enter the dividend: ";
    cin >> dividend;
    cout << "Enter the divisor: ";
    cin >> divisor;
    quotient = dividend / divisor;
    remainder = dividend % divisor;
    cout << "Quotient = " << quotient << endl;
    cout << "Remainder = " << remainder << endl;

    return 0;


Enter the dividend: 13
Enter the divisor: 5
Quotient = 2
Remainder = 3

In this program, we ask the user to input the dividend and divisor, and then compute the quotient and remainder using the / and % operators respectively.

It is important to note that the % operator only works with integer operands, it fails to calculate the remainder for the floating types.

Leave a Reply

Your email address will not be published. Required fields are marked *