C Program to sum the elements of an array

The following is a C program to find the sum of elements of an array:

Expected Output:

How it works

  1. We start by declaring variables arr and sum to store the array and the sum respectively. Note that the variable sum is initialized to 0.
  2. In lines 14-18, we have a loop which prompts the user to enter elements into the array.
  3. In lines 21-24, we have a second for loop to sum the elements of an array.
  4. In line 25, we print the sum using the print statement.

Recommended Reading:

Leave a Comment

%d bloggers like this: