C++ Program to Find Quotient and Remainder


Quotient and Remainder are parts of division along with dividend and divisor.

The number which we divide is known as the dividend. The number which divides the dividend is known as the divisor. The result obtained after the division is known as the quotient and the number left over is the remainder.

dividend = divisor * quotient + remainder

For Example: If 15 is divided by 7, then 2 is the quotient and 1 is the remainder. Here, 15 is the dividend and 7 is the divisor.

15 = 7 * 2 + 1

A program to find quotient and remainder is as follows:

Example

 Live Demo

#include <iostream>
using namespace std;
int main() {
   int divisor, dividend, quotient, remainder;
   dividend = 15;
   divisor = 7;
   quotient = dividend / divisor;
   remainder = dividend % divisor;
   cout << "Dividend is " << dividend <<endl;
   cout << "Divisor is " << divisor <<endl;
   cout << "Quotient is " << quotient << endl;
   cout << "Remainder is " << remainder;
   return 0;
}

Output

Dividend is 15
Divisor is 7
Quotient is 2
Remainder is 1

In the above program, the quotient is obtained by dividing the dividend by the divisor. The remainder is obtained by using the modulus operator on dividend and divisor.

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

After that the dividend, divisor, quotient and remainder are displayed.

cout << "Dividend is " << dividend <<endl;
cout << "Divisor is " << divisor <<endl;
cout << "Quotient is " << quotient << endl;
cout << "Remainder is " << remainder;

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 23-Jun-2020

8K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements