C Program to find the sum of elements in the given Array
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],i,n,sum=0;
clrscr();
printf("Enter the number of elements\n");
scanf("%d",&n);
printf("Now enter %d elements\n",n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
sum=sum+a[i];
}
printf("The sum of elements in the Array is %d",sum);
getch();
}
OUTPUT
Enter the number of elements6
Now enter 6 elements
10 20 30 110 50 100
The sum of elements in the Array is 320
------------------------------------------------------------------------------------------------------------