Algorithm
-
Input:
- Read
dividendanddivisorfrom the user.
- Read
-
Calculate Quotient and Remainder:
- Compute
quotientby dividingdividendbydivisor. - Compute
remainderby finding the remainder of the division ofdividendbydivisorusing the modulo operator%.
- Compute
-
Output:
- Display or output the values of
quotientandremainder.
- Display or output the values of
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
Enter dividend: 13
Enter divisor: 4
Quotient = 3
Remainder = 1
Enter divisor: 4
Quotient = 3
Remainder = 1
Demonstration
C++ Programing to Find Quotient and Remainder-DevsEnv