Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- double sumArr(double* arr, int length, int b){
- if (b == length)
- {
- return 0;
- }
- return arr[b] + sumArr(arr, length, b + 1);
- }
- int main(){
- double arr[] = {-2, 0, 9, 17, 5, 4};
- printf("Sum of array is: %.2f\n", sumArr(arr, 6, 0));
- return 0;
- }
Add Comment
Please, Sign In to add comment