Find quotient and remainder | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 2

Find quotient and remainder

25th Feb 2019, 4:42 AM
Rosemarie Lapinig
Rosemarie Lapinig - avatar
2 Respuestas
+ 5
For quotient we use / operator and for remainder we use % operator in c++ e.g. int a=10,b=3; int c = a/b; // this will give 3 int d= a%b; // this will give 1 cout<<c<<" "<<d; Output‚Äč: 3 1
25th Feb 2019, 5:01 AM
Sinjini Das
Sinjini Das - avatar
+ 5
#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; } Output Enter dividend: 13 Enter divisor: 4 Quotient = 3 Remainder = 1
25th Feb 2019, 9:13 AM
Ashutosh Sharma
Ashutosh Sharma - avatar