Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Write the definition of a function isMultipleOf , that receives two integer arguments and returns true if the first argument is a multiple of the second. Otherwise false is returned.

So, if the arguments are 27 and 8 the function returns false because 27 is not a multiple of 8. But if the arguments are 34 and 17 the function returns true because 34 is a multiple of 17 (2*17 is 34).
Posted

1 solution

What you want is the modulus ( % ) operator.

http://www.cprogramming.com/tutorial/modulus.html[^]
 
Share this answer
 
Comments
Member 10986520 4-Aug-14 17:18pm    
This is what I got so far...
class isMultipleOf
{
private:
double x;
double y;
public:
isMultipleOf()
{ set("", ""); }
};
bool isMultipleOf(int x, int y)
{
int result;
cin >> x;
cin >> y;
if ( x%y==0)
{
cout << result << endl;
}
else
{
result ? true : false;
}
return
Am I doing it right?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900