C++ Program to find quotient and remainder


In this program, You will learn how to find quotient and remainder in C++.


2 = 10 / 5

0 = 10 % 5

Example: How to find quotient and remainder in C++

#include<iostream>
using namespace std;

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

    c = a / b;
    d = a % b;

    cout << "Quotient is:" << c;
    cout << "\nRemainder is:" << d;

    return 0;
}

Output:

Enter first number:10
Enter second number:3
Quotient is:3
Remainder is:1