# C++ Program to find Quotient and Remainder of two Integers entered by User

January 17, 2023, Learn eTutorial
1226

In this C++ program, we will learn to find the quotient and remainder.

## How can we calculate the quotient and remainder of a g?

1. The quotient is the resultant value that we got after division

Quotient = dividend / divisor

2. The remainder is the leftover integer after one integer by another to produce an integer quotient.

Remainder = dividend % divisor.

For example 32 / 6

Where,

• 32 is the dividend
• 6 is the divisor
• Quotient = 6
• remainder = 2;

## How can we implement a C++ program to find the quotient and the remainder?

• Here the user is asked to enter two integer numbers.
• A divisor and a dividend. Read the dividend to the variable ‘dividend’ and the divisor to the variable ‘divisor’.
• The quotient is computed by using the arithmetic division operator ‘/’.
• The remainder is computed by using the modulus operator ‘%’.
• Print the results.

### Algorithm

Step 1:  Call the header file` iostream.`

Step 2: Use the `namespace std.`

Step 3: Open the integer type main function;` int main().`

Step 4: Declare integer variables; dividend, divisor, quotient, remainder;

Step 5: Print a message to enter the dividend.

Step 6: Read the number into the variable dividend.

Step 7: Print a message to enter the divisor.

Step 8: Read the number into the variable divisor.

Step 9: calculate the quoient = dividend / divisor; remainder = dividend % divisor;

Step 10: Print the quotient and remainder

Step 11: Exit.

## C++ Source Code

```                                          ```#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

```Run 1
-----------
Enter dividend: 45
Enter divisor: 5
Quotient = 9
Remainder = 0

Run 2
---------
Enter dividend: 96
Enter divisor: 7
Quotient = 13
Remainder = 5```

VIEW ALL
VIEW ALL