/* File: sum1.c A simple recursive function to compute the sum of the elements of an array. */ #include int sum (int A[], int high) { if (high < 0) return 0 ; if (high == 0) return A[0] ; return A[high] + sum(A,high-1) ; } main(){ int A[5] = {1, 4, 9, 3, 2} ; int s ; s = sum(A, 4) ; printf("sum A[0..4] = %2d\n", s) ; s = sum(A, 0) ; printf("sum A[0..0] = %2d\n", s) ; s = sum(A, 1) ; printf("sum A[0..1] = %2d\n", s) ; }