A program that reads in two integers and determines an prints if the first is a multiple of the second.

```
/******************************************************
** Name:
** Filename: multiples.cpp
** Project #: Deitel & Deitel 1.32
** Project Description: Write a program that reads in two integers
and determines an prints if the first is a multiple of the second.
** Output:
First integer is a multiple of second integer
No
Yes
If Yes show that first number is multiple of second
by displaying that first number divided by second number
is a whole number with no remainder
** Input:
Two integers
** Algorithm:
Explain function to be performed
direct user to input two integers
take the two integers that are input and
determine if the first integer divided by
the second integer will result in a whole
number with no remainder. If no remainder,
print Yes, first number is a multiple of second
number and explain. Then end program. If there
is a remainder print No, first number is not a
multiple of second number and explain.
Then end program.
******************************************************/
// Include files
#include <iostream> // used for cin, cout
#include <conio.h>
using namespace std;
// Global Type Declarations
// Function Prototypes
void instruct (void);
void pause ();
//Global Variables - should not be used without good reason.
int main ()
{
// Declaration section
int integer1, integer2, answer, quotient, result;
// Executable section
instruct ();
cout << "Enter first integer: ";
cin >> integer1;
cout << "Enter second integer: ";
cin >> integer2;
answer = integer1 % integer2;
quotient = integer1 / integer2;
result = quotient * integer2;
if ( answer == 0 )
cout << "\n**** Yes "<< integer1 << " is a multiple of "
<< integer2 << " ****" << endl;
if ( result == integer1 )
cout << "\nWe know "<< integer1 << " is a multiple of "
<< integer2 << " because " << integer1 << " divided by "
<< integer2 << " equals\na whole number which is "
<< quotient << " and " << quotient << " multiplied by "
<< integer2 << " equals " << result << endl;
if ( answer != 0 )
cout << "\n**** No "<< integer1 << " is not a multiple of "
<< integer2 << " **** "<< "\n\nWe know this because "
<< integer1 << " divided by "
<< integer2 << " equals " << quotient
<< " with a remainder of " << answer << endl;
pause ();
return 0;
}
void instruct (void)
{
// Declaration section
// Executable section
cout << "Enter two integers below. The program will then determine \n"
<< "if the first number entered is a multiple of the second \n"
<< "number entered.\n "<< endl;
}
void pause ()
{
// Declaration section
// Executable section
cout << "\nPress any key to continue...";
getch();
cout << "\r";
cout << " ";
cout << "\r";
}
/*
Program Output
Enter two integers below. The program will then determine
if the first number entered is a multiple of the second
number entered.
Enter first integer: 625
Enter second integer: 5
**** Yes 625 is a multiple of 5 ****
We know 625 is a multiple of 5 because 625 divided by 5 equals
a whole number which is 125 and 125 multiplied by 5 equals 625
Press any key to continue...
*/
```