Consider dividing 20162019 by 301 Write its quotient and rem
Consider dividing 20162019 by 301. Write its quotient and remainder using the integer functions.
I know you have to use the mod function but im not sure how. i think its 20162019 mod 301 but no sure. Pleas help and show all steps!!!
Solution
//C++ code
 #include <fstream>
 #include <iostream>
 #include <cstdlib>
 #include <string>
 #include <vector>
 #include <cmath>
using namespace std;
int main()
 {
 int divisor;
 int dividend;
 int quotient = 0;
 int remainder;
cout << \"Enter dividend: \";
 cin >> dividend;
cout << \"Enter divisor: \";
 cin >> divisor;
// this process is similar to the MODULUS operator
 // subtract divisor from dividend till dividend is not negative
 while(dividend > 0)
 {
 dividend = dividend - divisor;
// increment quotient value
 quotient++;
 }
// remainder will be the leftover dividend
 remainder = dividend;
// if remainder is less than 0, the remainder will be the divisor plus the remainder obtained before
 if(remainder < 0 )
 remainder = remainder + divisor;
cout << \"Quotient: \" << quotient << \"\ \";
 cout << \"Remainder: \" << remainder << \"\ \";
return 0;
 }
/*
 output:
Enter dividend: 20162019
 Enter divisor: 301
 Quotient: 66983
 Remainder: 136
 */


