Summing an Array
An array means contiguous memory allocation whose base address is accessed by the array name. arr[1] means add the size of 1 element to the array depending on the type of the array to obtain the 1 element.
/*
http://www.ProbCOMP.com
An array means contiguous memory allocation whose base address is accessed by the array name.
arr[1] means add the size of 1 element to the array depending on the type of the array to obtain the
1 element.
*/
#include<stdio.h>
#define N 10
void main()
{
int arr[N];
printf("enter input %d numbers \n",N);
//taking input
for(int i=0;i<N;i++)
{
scanf("%d",&arr[i]);
}
//adding numbers
int sum=0;
for(int i=0;i<N;i++)
{
sum=sum+arr[i];
}
printf("%d",sum);
}
Download Program


