Write a recursive function that returns the sum of the first N integers of an array.
Write a main function to test your program.
Difficulty level
This exercise is mostly suitable for students
int sum(int tab[], int tab_size, int N)
{
if(N==1)
return tab[0];
return(tab[N-1]+sum(tab,tab_size,N-1));
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Set of integer in binary search trees