Following is the program to find the sum of all the elements of the array as per the array input from the user :
#include<stdio.h>
int main(){
int n,sum=0;
printf("Enter the length of array ");
scanf("%d",&n);
int a[n];
printf("Enter the elements of array\n");
for(int i=0;i<n;i++){
scanf("%d",&a[i]);\
}
for(int j=0;j<n;j++){
sum += a[j];
}
printf("Sum: %d",sum);
return 0;
}
