Sum of Array Elements

Code

#include < stdio.h>
#include < conio.h>

int main(){

int a[10];
int i, N, sum=0;

printf("Input the number of elements to be stored in the array :");
scanf("%d",&N);

printf("Input elements of array :");

for ( i=0 ; i< N ; i++)
scanf("%d",&a[i]);

for ( i=0 ; i< N ; i++){
sum += a[i] ;

printf("Sum of all elements stored in the array is : %d\n\n", sum);
return 0;
}

Memory

a[0]

1

a[1]

2

a[2]

3

a[3]

4

a[4]

5

a[5]

6

a[6]

7

a[7]

8

a[8]

9

a[9]

10


i

a[i]


sum

0

Enter Values



Input Array Elements