You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
413 B
C
19 lines
413 B
C
5 years ago
|
/*Addition of all elements of array*/
|
||
|
#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);
|
||
|
}
|