C++ Program to Find Quotient and Remainder

Here is a C++ program to find quotient and remainder or two numbers. To find the quotient and remainder or two numbers, we will first take two integers as input from user using cin and stores them in two local variables. Let the two input numbers be A and B. To find quotient and remainder of A/B we will use division(/) and modulus(%) operator.

Operator Description Syntax Example
/ Divides numerator by denominator a / b 15 / 5 = 3
% Returns remainder after an integer division a % b 16 % 5 = 1

C++ program to find quotient and remainder when an integer is divided by another integer

#include <iostream>

using namespace std;

int main() {
    
    int numerator, denominator, quotient, remainder;
    cout << "Enter Numerator\n";
    cin >> numerator;
    cout << "Enter Denominator\n";
    cin >> denominator;
    
    quotient = numerator/denominator;
    remainder = numerator%denominator;
    
    cout << "Quotient is " << quotient << endl;
    cout << "Remainder is " << remainder;

    return 0;

}
Output
Enter Numerator
10
Enter Denominator
2
Quotient is 5
Remainder is 0

Enter Numerator
13
Enter Denominator
3
Quotient is 4
Remainder is 1

Recommended Posts
C++ Program to Find LCM and GCD of Two Numbers
C++ Program to Add Two Numbers
C++ Program to Multiply two Numbers
C++ Program to Swap Two Numbers
C++ Program to Find Power of a Number
C++ Program to Find Product of Two Numbers
C++ Program to Find Factorial of a Number
C++ Program to Find GCD of Two Numbers
C++ Program to Make a Simple Calculator
All C++ Programs