Cpp program to find Quotient and Remainder
Following is the code which help in the understanding how to compute quotient and remainder.
Code:
#include <iostream>
using namespace std;
int main()
{
int divis, divid, quot, rem;
cout << "Enter dividend :-"<<endl;
cin >> divid;
cout << "Enter divisor:- "<<endl;
cin >> divis;
quot = divid / divis;
rem = divid % divis;
cout << "Quotient = " << quot << endl;
cout << "Remainder = " << rem<<endl;
return 0;
}
Output:
In the above program, declare 4 variables of int data type and take input from the user by input method then divide the dividend by divisor store in quotient which is the quotient .
The modulus of dividend and divisor is store in the remainder because modulus computes the remainder of the two number.
If you have any problem in understanding of the above program then write a query in the below comment section.
Comments
Post a Comment