This is a simple program written in the C++ programming language that calculates the quotient and remainder of a division operation.
#include <iostream>
using namespace std;
int main () {
int dividend, divisor, quotient, remainder;
cout << "Please enter dividend: " << endl;
cin >> dividend;
cout << "Please enter divisor: " << endl;
cin >> divisor;
quotient = dividend / divisor;
remainder = dividend % divisor;
cout << "Quotient is: " << quotient << endl;
cout << "Remainder is: " << remainder;
return 0;
}
Please enter dividend: 75
Please enter divisor: 8
Quotient is: 9
Remainder is: 3
The first section declares four integer variables: dividend, divisor, quotient, and remainder.
The next section uses the cout statement to print the prompt “Please enter dividend: ” and the cin statement to read the value of the dividend from the user. The same process is repeated for the divisor.
The division operation is performed with the line quotient = dividend / divisor;. The division operator (/) returns the quotient of the division, and it is stored in the quotient variable.
The remainder is calculated with the line remainder = dividend % divisor;. The modulo operator (%) returns the remainder of the division and it is stored in the remainder variable.
The last section uses the cout statement to display the values of the quotient and remainder to the user.
Finally, the return 0; statement indicates that the program has executed successfully and returns a zero status to the operating system.