AR11


TEST CASE 1 

INPUT
10
5 1 23 5 47 4 3 1 2 12
OUTPUT
103

TEST CASE 2 

INPUT
8
12 15 14 30 4 19 23 10
OUTPUT
127

#include <stdio.h>
int maxSum(int a[], int n, int k);
int main() {
 int n,a[50],i,k=0,res;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  res=maxSum(a,n,k);
  printf("%d",res);
  return 0;
}
int maxSum(int a[50],int n,int k)
{
  int i;
  for(i=0;i<n;i++)
  {
    if(a[i]>0)
   k = k+a[i];
  }
  return k;
 
}

Comments

Popular posts from this blog

AR1

SER12

AR15