This program initializes an array ‘arr’ with some values, calculates the number of elements in the array, and then uses a loop to iterate through the array, adding each element to the sum
variable. Finally, it prints the sum to the console. You can modify the values in the ‘aar’ array or use a different array to test the program with other sets of numbers.
Program :
#include<stdio.h>
int main()
{
int arr[100], size, i, sum = 0;
printf(“Enter array size\n”);
scanf(“%d”,&size);
printf(“Enter array elements\n”);
for(i = 0; i < size; i++)
scanf(“%d”,&arr[i]);
for(i = 0; i < size; i++)
sum = sum + arr[i];
printf(“Sum of the array = %d\n”,sum);
return 0;
}