AR14


TEST CASE 1 

INPUT
5
1 2 3 4 5
OUTPUT
15

TEST CASE 2 

INPUT
6
4 5 7 9 5 2
OUTPUT
32


#include <stdio.h> 
int findSum(int A[], int N) 
{ 
    if (N <= 0) 
        return 0; 
    return (findSum(A, N - 1) + A[N - 1]); 
} 
  
// Driver code 
int main() 
{ int N;
 scanf("%d",&N);
    int A[N],i;
  for(i=0;i<N;i++)
    scanf("%d",&A[i]); 
    printf("%d", findSum(A, N)); 
    return 0; 
}

Comments

Popular posts from this blog

AR1

SER12

AR15