Find Quotient and Remainder

Beginner-friendly C++ program that finds the quotient and remainder when one number is divided by another.

C++Beginner
C++
#include <iostream>
using namespace std;

int main() {
    int dividend, divisor;
    
    cout << "Enter dividend: ";
    cin >> dividend;
    
    cout << "Enter divisor: ";
    cin >> divisor;
    
    // Method 1: Using division and modulus operators
    int quotient = dividend / divisor;
    int remainder = dividend % divisor;
    
    cout << "Quotient: " << quotient << endl;
    cout << "Remainder: " << remainder << endl;
    
    return 0;
}

Output

Enter dividend: 25
Enter divisor: 4
Quotient: 6
Remainder: 1

Find Quotient and Remainder in C++

This program teaches you how to find the ## quotient and ## remainder when one integer is divided by another. This is a very common operation in mathematics and programming, especially when working with loops, number problems, and algorithms.

Understanding Dividend, Divisor, Quotient, and Remainder

When you divide one whole number by another:

  • Dividend → the number you want to divide

  • Divisor → the number you are dividing by

  • Quotient → the whole number result of the division

  • Remainder → what is left after division

Example:
25 ÷ 4 = 6 remainder 1
Here:

  • Dividend = 25
  • Divisor = 4
  • Quotient = 6
  • Remainder = 1

Using Division and Modulus Operators

Two operators are used:

  1. Division ( / )

    Gives the quotient (whole number result).
    For example: 25 / 4 = 6

  2. Modulus ( % )

    Gives the remainder.
    For example: 25 % 4 = 1

So the program calculates:

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

These two lines give the complete result of the division operation.

Summary

  • The division operator (/) gives the quotient.
  • The modulus operator (%) gives the remainder.
  • This is the fastest and most direct way to solve quotient–remainder problems in C++.
  • Understanding quotient and remainder is important for number patterns, loops, and many algorithmic problems.

This beginner program helps you understand how arithmetic operators work and prepares you for more complex logic in future programs.