Sum of array elements in C programming

Image result for c programming

Sum of array elements in C programming
Code:

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

No comments