#include<stdio.h>
#define MAX 100
void main()
{
    int arr[MAX],n,i,sum=0;
    printf("Enter size of Array: ");
    scanf("%d",&n);
    printf("Enter %d elements\n",n);
    for(i=0; i<n; i++)
    {
       scanf("%d",&arr[i]);
    }
    for(i=0; i<n; i++)
    {
       sum= sum+arr[i];
    }
    printf("Sum of array : %d ",sum);
}

Output :

Enter size of Array: 10
Enter 10 elements
1
2
3
4
5
6
7
8
9
10
Sum of array : 55

 

Add a Comment

Add a Comment