(Multiples) Write a function multiple that determines for a pair of integers whether the sec- ond is a multiple of the first. The function should take two integer arguments and return true if the second is a multiple of the first, false otherwise. Use this function in a program that inputs a series of pairs of integers.

What will be an ideal response?

```
// Determines whether, for a pair of integers,
// the second is a multiple of the first.
#include
using namespace std;

bool multiple( int, int ); // function prototype

int main()
{
int x; // first integer
int y; // second integer

// loop 3 times
for ( int i = 1; i <= 3; i++ )
{
cout << "Enter two integers: ";
cin >> x >> y;
// determine if second is multiple of first
if ( multiple( x, y ) )
cout << y << " is a multiple of " << x << "\n\n";
else
cout << y << " is not a multiple of " << x << "\n\n";
} // end for

cout << endl;
} // end main

// multiple determines if b is multiple of a
bool multiple( int a, int b )
{
return !( b % a );
} // end function multiple
```

Computer Science & Information Technology

You might also like to view...

Sharing files is a benefit of a network

Indicate whether the statement is true or false

Computer Science & Information Technology

To import information into Excel from a web page, you must first open the page with:

A) an Internet browser. B) Microsoft Access. C) Notepad. D) Microsoft Word.

Computer Science & Information Technology