Ok, i am busy learning recursion. I want a function that receives two int and add everyting from int a to int b. then it must return the sum
I cant use sum because with each recursion sum gets int to zero. I dont want to pass a variable for sum to the function and i dont want to use a global variable... any suggestions for the noob?Code:double Function(int Start, int End) { int sum=0; if(End>=Start) { cout<<Start<<endl; sum+=Start; Start++; Function(Start ,End); } else return sum; }
Thanks