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
- #include<stdio.h>
- main()
- {
- int n,i,sum=0;
- scanf("%d",&n);
- int a[n];
- for(i=0;i<n;i++)
- {
- scanf("%d",&a[i]);
- sum=sum+a[i];
-
- }
- printf("%d",sum);
- }