Produce a program that test, for two input integers, whether the second divides exactly into the first.
At the time of writing I'm starting to learn c++, so I decided to write the solution in that language instead of PHP.
int main ()
int iFirst, iSecond;
cout << "This program will check if a number can be divided into another number.\n";
cout << "Enter the first number.\n>";
cin >> iFirst;
cout << "Enter the second number.\n>";
cin >> iSecond;
if (iFirst % iSecond)
cout << iSecond << " doesn't divide exactly into " << iFirst << ".";
cout << iSecond << " divides exactly into " << iFirst << ".";
Here's the same application with a different implementation.
C:\code>divisor 9 3
3 divides exactly into 9
using namespace std;
int main(int argc, char **argv)
int n1 = atoi(argv);
int n2 = atoi(argv);
if (n1 % n2)
printf("%d doesn't divide into %d", n2, n1);
printf("%d divides exactly into %d", n2, n1);