Sum of positive numbers in C Programming

Image result for c programming

Sum of positive numbers in C Programming
Code:
  #include<stdio.h>
int main(){
  int n,a[20],i,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]>0)
      sum=sum+a[i];
  }
  printf("The sum of the positive numbers in the array is %d",sum);
  return 0;
}

No comments