1//made by Kashish Vaid
2#include <conio.h>
3
4
5int main()
6{
7 int a[1000],i,n,sum=0;
8
9 printf("Enter size of the array : ");
10 scanf("%d",&n);
11
12 printf("Enter elements in array : ");
13 for(i=0; i<n; i++)
14 {
15 scanf("%d",&a[i]);
16 }
17
18
19 for(i=0; i<n; i++)
20 {
21
22 sum+=a[i];
23 }
24 printf("sum of array is : %d",sum);
25
26 return 0;
27}
28//made by kashish vaid
1/**
2 * C program to find sum of all elements of array
3 */
4
5#include <stdio.h>
6#define MAX_SIZE 100
7
8int main()
9{
10 int arr[MAX_SIZE];
11 int i, n, sum=0;
12
13 /* Input size of the array */
14 printf("Enter size of the array: ");
15 scanf("%d", &n);
16
17 /* Input elements in array */
18 printf("Enter %d elements in the array: ", n);
19 for(i=0; i<n; i++)
20 {
21 scanf("%d", &arr[i]);
22
23 // Add each array element to sum
24 sum += arr[i];
25 }
26
27 printf("Sum of all elements of array = %d", sum);
28
29 return 0;
30}
1/**
2 * C program to find sum of all elements of array
3 */
4
5#include <stdio.h>
6#define MAX_SIZE 100
7
8int main()
9{
10 int arr[MAX_SIZE];
11 int i, n, sum=0;
12
13 /* Input size of the array */
14 printf("Enter size of the array: ");
15 scanf("%d", &n);
16
17 /* Input elements in array */
18 printf("Enter %d elements in the array: ", n);
19 for(i=0; i<n; i++)
20 {
21 scanf("%d", &arr[i]);
22 }
23
24 /*
25 * Add each array element to sum
26 */
27 for(i=0; i<n; i++)
28 {
29 sum = sum + arr[i];
30 }
31
32
33 printf("Sum of all elements of array = %d", sum);
34
35 return 0;
36}