I am writing a recursive function that has two functions, one to add numbers from 0 to 10 and then the other to retrieve the first function return value and subtract it until it reaches 0. Although, my code only adds them up 10 for the calls. Can someone shed some light. thanks.
#include <iostream>
#include <fstream>
using namespace std;
static int recurse(int count)
{
cout << count << "\n";
if (count < 10)
{
recurse(count + 1);
}
int aRet = count;
return count;
}
static int minusRecusive(int minus)
{
recurse(1);
cout << "\n\t" << minus;
int a =0;
minus = recurse(a);
if (minus < 1)
{
recurse(minus - 1);
}
return minus;
}
int main()
{
minusRecusive(1);
cin.get();
}
recurseis nothing butint recurse (int count){return count;}, is that what you wanted?minusRecursiveshould probably all itself rather than the other function.