In this C++ program, we will learn to find the quotient and remainder.
Quotient = dividend / divisor
Remainder = dividend % divisor.
For example 32 / 6
Where,
Step 1: Call the header file iostream.
Step 2: Use the namespace std.
Step 3: Open the integer type main function; int main().
Step 4: Declare integer variables; dividend, divisor, quotient, remainder;
Step 5: Print a message to enter the dividend.
Step 6: Read the number into the variable dividend.
Step 7: Print a message to enter the divisor.
Step 8: Read the number into the variable divisor.
Step 9: calculate the quoient = dividend / divisor; remainder = dividend % divisor;
Step 10: Print the quotient and remainder
Step 11: Exit.
#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;
}
Run 1 ----------- Enter dividend: 45 Enter divisor: 5 Quotient = 9 Remainder = 0 Run 2 --------- Enter dividend: 96 Enter divisor: 7 Quotient = 13 Remainder = 5