Algorithm
-
Input:
- Read
dividend
anddivisor
from the user.
- Read
-
Calculate Quotient and Remainder:
- Compute
quotient
by dividingdividend
bydivisor
. - Compute
remainder
by finding the remainder of the division ofdividend
bydivisor
using the modulo operator%
.
- Compute
-
Output:
- Display or output the values of
quotient
andremainder
.
- 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