Algorithm


  1. Input:

    • Read dividend and divisor from the user.
  2. Calculate Quotient and Remainder:

    • Compute quotient by dividing dividend by divisor.
    • Compute remainder by finding the remainder of the division of dividend by divisor using the modulo operator %.
  3. Output:

    • Display or output the values of quotient and remainder.

 

Code Examples

#1 Code Example-C++ Programing Compute quotient and remainder

Code - C++ Programming

#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;
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
Enter dividend: 13
Enter divisor: 4
Quotient = 3
Remainder = 1
Advertisements

Demonstration


C++ Programing to Find Quotient and Remainder-DevsEnv