Where do you give num and num1 a value before you pass it to either the recursive or the iterative process? Shouldn't line 22 and 23 be between line 28 and 29?
Expand line 46 to three lines:
double temp = fnum * wk7recur(fnum,inum -1);
cout << temp << endl;
return temp;
num1 will be an int. It will control how many recursive calls to the recursive function there will be and how many times through the loop you will need to go. To generate a new running total each time through the loop you can use a holding variable and the *= operator.
Basically you are calculating fnum raised to the inum power, or something like that, with either approach.
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Offline 2,253 posts
since Jul 2005