C++ Program to Find Quotient and Remainder

Problem

Write a C++ Program to Find Quotient and Remainder.

Solution

This program asks the user to enter two integers (divisor and dividend) and computes the quotient and remainder. To compute the quotient and remainder, both the divisor and the dividend must be integers.

Here’s a simple C++ program for calculating the quotient and remainder in the C++ programming language.

#include <iostream>
using namespace std;

int main()
{
    int divisor, dividend, quotient, remainder;

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

    cout << "\nEnter divisor : ";
    cin >> divisor;

    quotient = dividend / divisor;
    remainder = dividend %% divisor;

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

    return 0;
}

Output