Vasilena

PracticeDayThreeExercise8

Jul 8th, 2021 (edited)
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. double sumArr(double* arr, int length, int b){
  5.     if (b == length)
  6.     {
  7.         return 0;
  8.     }
  9.     return arr[b] + sumArr(arr, length, b + 1);
  10. }
  11.  
  12. int main(){
  13.     double arr[] = {-2, 0, 9, 17, 5, 4};
  14.     printf("Sum of array is: %.2f\n", sumArr(arr, 6, 0));
  15.     return 0;
  16. }
  17.  
Add Comment
Please, Sign In to add comment