How can I make a function which perform an arithmetic operation then performs a statement based on the type of number that is made. e.g. (decimal, integer)
example:
1 2 3 4
int divide(int x, int y)
{
return x / y;
}
this is just a forward declaration of a function, but would I be able to make a function that looks at the number and can decipher whether it is a decimal or a negative number or just an integer?
You need to go into a little more detail, but I believe that you want, going off of your example, to use modulus. For Example:
1 2 3 4 5 6 7 8 9 10 11
int divide(int x, int y) {
// Need to make sure y isn't 0
if (y == 0)
return y;
// Check to see if there is going to be a remainder
if (x % y > 0)
std::cout << "There was a remainder!\n";
return (x / y);
}
If you provide a little more detail, I might be able to help you further.