fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int oddSum(int arr[], int n)
  5. {
  6. if (n == 0)
  7. return arr[0];
  8. else if ((n-1) % 2 == 1)
  9. return arr[n] + oddSum(arr,n-1);
  10. else
  11. return oddSum(arr,n-1);
  12. }
  13.  
  14. int main()
  15. {
  16. int arr[3];
  17. arr[0]=3; arr[1]=4; arr[2]=7; arr[3]=1;
  18. printf("%d\n", oddSum(arr,3));
  19.  
  20. return 0;
  21. }
  22.  
Runtime error #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
Standard output is empty