1d array in c

Solutions on MaxInterview for 1d array in c by the best coders in the world

showing results for - "1d array in c"
Maja
08 Oct 2018
1#include<stdio.h>
2
3int main()
4{
5    int arr[5], i, s = 0;
6
7    for(i = 0; i < 5; i++)
8    {
9        printf("Enter a[%d]: ", i);
10        scanf("%d", &arr[i]);
11    }
12
13    for(i = 0; i < 5; i++)
14    {
15        s += arr[i];
16    }
17
18    printf("\nSum of elements = %d ", s);
19
20    // signal to operating system program ran fine
21    return 0;
22}
23