C Programming Code Examples C > Arrays and Matrices Code Examples Program to find sum of array elements Program to find sum of array elements Write a C program to read elements in an array and find the sum of all elements of the array. C program to find sum of elements of the array. How to add elements of an array using for loop in C programming. Logic to find sum of array elements in C programming. #include <stdio.h> #define maxsize 100 int main() { int arr[maxsize]; int j, n, sum=0; /* Input size of the array */ printf("Enter size of the array: "); scanf("%d", &n); /* Input elements in array */ printf("Enter %d elements in the array: ", n); for(j=0; j<n; j++) { scanf("%d", &arr[j]); // Adds each element of array to sum sum += arr[j]; } printf("Sum of all elements of array = %d", sum); return 0; }