1. ## my Quiz

hi all

today I had a quiz in template and recursion
it was easy I did will , but when I tried to solve the questions in VB it gave me different answers I will not say my answers untill I see urs to compare them with mine.
so help me pleas to find where the errors, is it from me or the compiler?

Code:
```#include<iostream>
using namespace std;

int sum(int m,int n){
if (m==0)
return n+1;
if (n==0)
return sum (m-1 , 1);
else
sum (m-1 , sum ( m , n-1));
cout<<"done";
}

int main(){

cout<<sum(2,5);

return 0;}```

2. Oh my goodness, dude, learn to indent!

3. What's it supposed to calculate? 2 + 5? Note that in some cases sum doesn't return anything, so it can't give good results.

4. Mmm, looks like this - http://en.wikipedia.org/wiki/Ackermann_function
So (apart from the coding error anon spotted), lets say arithmetic overflow, or you blow the stack.

hi all

today I had a quiz in template and recursion
it was easy I did will , but when I tried to solve the questions in VB it gave me different answers I will not say my answers untill I see urs to compare them with mine.
so help me pleas to find where the errors, is it from me or the compiler?

Code:
```#include<iostream>
using namespace std;

int sum(int m,int n){

if (m==0)
return n+1;
else if (n==0)
return sum (m-1 , 1);
else
sum (m-1 , sum ( m , n-1));

cout<<"done";
}

int main(){

cout<<sum(2,5);

return 0;}```
Notice the bolded item that you missed.

Also, the only output here is "done".

6. All elses in the function are redundant, since the then branches return early.