HackerRank C- Simple Array Sum



Complete the simpleArraySum function in the editor below. It must return the sum of the array elements as an integer.

simpleArraySum has the following parameter(s):

ar: an array of integers



  1. #include<stdio.h>
  2. main()
  3. {
  4. int n,i,sum=0;
  5. scanf("%d",&n);
  6. int a[n];
  7. for(i=0;i<n;i++)
  8. {
  9. scanf("%d",&a[i]);
  10. sum=sum+a[i];
  11. }
  12. printf("%d",sum);
  13. }

download android app