Question #31251

Write a program to get three numbers from user for integer variables a, b and c. If a isnot zero, find out whether it is the common divisor of b and c.

Expert's answer

#include <iostream>
using namespace std;

int main() {
int a, b, c;
cout << "Input a: ";
cin >> a;
cout << "Input b: ";
cin >> b;
cout << "Input c: ";
cin >> c;
if (a != 0) {
& if (b % a == 0 && c % a == 0)
cout << "a is common divisor of b and c";
& else
cout << "a isn't a common divisor of b and c";
& cout << endl;
}
}
LATEST TUTORIALS
APPROVED BY CLIENTS