Q16.Write a code to find sum of array elements

Array :- An array is a collection of data items, all of which are of the same type, using a common name.
For Example :-
input : arr[]={ 2, 5, 3, 6, 4 }
output : 20

So as we can see that the sum of elements in arr[] = { 2, 5, 3, 6, 4 } is 20 so the output is 20.

Algorithm for Array Sum

START
Step 1 : Take an array Arr and define its values
Step 2 : Loop for each value of Arr
Step 3 : Add each element to ‘sum’ variable
Step 4 : After the loop finishes, display ‘sum’
STOP

Code for Array Sum

Output

Sum of array is = 20

Recommended Programs
Program to find factorial of a number
Program to count number of digits in a number