Răspuns:
#include <iostream>
using namespace std;
int a, b, c, r;
int main()
{
cout << "a="; cin >> a;
cout << "b="; cin >> b;
if (a*b==0) cout << "eroare";
else
{
if (a>b)
{
c=a/b; r=a%b;
}
else
{
c=b/a; r=b%a;
}
cout << "catul=" << c << endl;
cout << "restul=" << r;
}
return 0;
}
Explicație: