idastan97

CSCI151 L18 P2

Oct 2nd, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.26 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int addSubarray(int x[], int from, int to){
  4.     if (from==to) {
  5.         return x[from];
  6.     }
  7.     return addSubarray(x, from+1, to)+x[from]; 
  8. }
  9.  
  10. int main(){
  11.     int x[]={5, 2, 6, 9, -5, 0};
  12.     printf("%i", addSubarray(x, 1, 3));
  13.     return 0;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment