I'm a beginner but I need help bad!

Hey guys. I'm quite the beginner at C++. This question has been bugging me for hours and I CAN'T SEEM TO GET IT DOWN. Please help me! This is what I've been working on...

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).

This is what I've come up with so far...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  class isMultipleOf
{
	private:
	double x;
	double y;
	public:
	isMultipleOf()
	{ set("", ""); }
};
bool isMultipleOf(int x, int y)
{
		
	cin >> x;
	cin >> y;
	cout << (x/y) << endl;
	return x%y==0;
}
Why are you creating a class, your assignment states to:
Write the definition of a function


This function is going to get it's input from the parameters, not from the user. You'll need to create a main() that supplies the values for the parameters and calls the function.



so would I still be using the bool?
Yes. You still want isMultipleOf to return true or false
so I should delete the class then what? I still have to cin x and y right?
I finally just decided just to delete everything except the bool and it worked!!!
Here it is!!!

bool isMultipleOf(int x, int y)
{
return x%y==0;
}
Topic archived. No new replies allowed.