0

I'm stuck on a homework problem. Just not sure where I'm going wrong, I think my code should work and it doesn't, and I'm not sure why.

The assigned problem is:

Recursive Multiplication: Write a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition (7 * 4 = 7 + 7 + 7 + 7).

And my code:

```
#include <iostream>
#include<conio.h>
using namespace std;
int myMath(int, int);
int main()
{
int num1, num2;
cout << "Enter an integer.\n";
cin >> num1;
cout << "Enter a second integer and I will multiply them.\n";
cin >> num2;
cout << "The total is: " << myMath(num1,num2) << ".\n";
getch();
return 0;
}
int myMath(int x, int y) {
int total;
if ( y > 0) {
total = total + x;
y--;}
else return total;
}
```

Any help would be very much appreciated.

Thanks,

Terz