I want to find out if the sum of even numbers in the array is equal to the sum of odd numbers, using only recursion and without any additional functions, except recursion and without any static variables.
If the sum of odd numbers is equal to the sum of even numbers, the function returns 1, else it returns 0. All the numbers in the array are non negative.
The function signature should look like this:
function(unsigned int a[], int n)
Until now I have written the following:
function(unsigned int a[], int n)
{
if(n==0) return 0;
return (a[0]%2)?((a[0]+function(a+1,n-1)):(-a[0]+function(a+1,n-1));
}
This function returns the total sum required but not the answer to the question (which is 1 if yes and 0 if no).
Yes this is a part of an assignment but I cannot solve it without additional functions that are not allowed.