In this tutorial, you will learn how to write a C++ Program to find the quotient and remainder of the division of two given numbers.

C++ Finding Quotient and Remainder Program

To find the quotient when a number is divided, use Arithmetic Division Operator, and to find the remainder, use Arithmetic Modulus Operator.

You may refer

Program

In the following C++ Program, we read two numbers from user, divide them, and then find the quotient and remainder.

main.cpp

</>
Copy
#include <iostream>
using namespace std;

int main() {
    int a, b;
    cout << "Enter first number  : ";
    cin >> a;
    cout << "Enter second number : ";
    cin >> b;

    int quotient, remainder;
    quotient = a / b;
    remainder = a % b;

    cout << "Quotient  : " << quotient << endl;
    cout << "Remainder : " << remainder << endl;
}

Output

Enter first number  : 14
Enter second number : 5
Quotient  : 2
Remainder : 4
Program ended with exit code: 0
Enter first number  : -15
Enter second number : 7
Quotient  : -2
Remainder : -1
Program ended with exit code: 0

Conclusion

In this C++ Tutorial, we learned how to find quotient and remainder when a number is divided by another.