programming-examples/c/Arrays/C Program for Addition of all elements of array.c
2019-11-15 12:59:38 +01:00

19 lines
413 B
C

/*Addition of all elements of array*/
#include<stdio.h>
#define MAX 100
void main()
{
int arr[MAX],n,i,sum=0;
printf("Enter size of Array: ");
scanf("%d",&n);
printf("Enter %d elements\n",n);
for(i=0; i<n; i++)
{
scanf("%d",&arr[i]);
}
for(i=0; i<n; i++)
{
sum= sum+arr[i];
}
printf("Sum of array : %d ",sum);
}