C++ Program to Find Quotient and Remainder

209
views
Find Quotient and Remainder
(Last Updated On: September 1, 2018)

In this example, you will learn to find quotient and remainder of a given dividend and divisor.

Finding Quotient and Remainder are some of the basic Mathematical operations, Here we’ll learn how to implement¬†it in Programming. In this program, to Find Quotient and Remainder, the user is asked to enter two integers (divisor and dividend) and computes the quotient and remainder.

To compute quotient and remainder, both divisor and dividend should be integers.

Program to Compute quotient and remainder

#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

Enter dividend: 13
Enter divisor: 4
Quotient = 3
Remainder = 1

The division operator / is computes the quotient (either between the 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).

Related Programs

Ask your questions and clarify your/others doubts on how to Find Quotient and Remainder by commenting. Documentation.

Please write to us at [email protected] to report any issue with the above content or for feedback.