**How to get quotient and remainder?**

Binary operator divide (/) returns the quotient, let suppose if dividend is 10 and divisor is 3, then quotient will be 3.

Binary operator modulus (%) returns the remainder, let suppose if dividend is 10 and divisor is 3, then remainder will be 1.

**C Solution:**

#include<stdio.h> /* * Prosen Ghosh * American International University - Bangladesh (AIUB) * */ void main(){ int dividend, divisor; int quotient, remainder; printf("Enter dividend: "); scanf("%d",÷nd); printf("Enter divisor: "); scanf("%d",&divisor); quotient= dividend/divisor; remainder= dividend%divisor; printf("Quotient: %d, Remainder: %d\n",quotient,remainder); }

```
```

**C++ Solution:**

#include<bits/stdc++.h> using namespace std; /* * Prosen Ghosh * American International University - Bangladesh (AIUB) * */ int main(){ int dividend, divisor; int quotient, remainder; cout << "Enter dividend: "; cin >> dividend; cout << "Enter divisor: "; cin >> divisor; quotient = dividend/divisor; remainder = dividend%divisor; cout << "Quotient: " << quotient << " Remainder: " << remainder << endl; return 0; }

## No comments:

## Post a Comment