// Write a program in C to find the sum of all elements of the array
#include<stdio.h>
int main(){
int a[100],n,i,sum=0;
printf("enter the number of elements\n");
scanf("%d",&n);
for (i = 0 ; i < n ; i++ )
{
printf("enter the number : ");
scanf("%d",&a[i]);
}
for ( i = 0 ; i < n ; i ++ )
{
sum = sum + a[i];
}
printf("sum = %d",sum);
return 0;
0 Comments