C program to print the sum of all numbers in a given array
kw.c
#include <stdio.h>
int main()
{
    int sum = 0;
    int arr[5] = {100, 15, 8, 45, 93};
    for (int i = 0; i < 5; i++)
    {
        sum = sum + arr[i];
    }
    printf("The addition of a given array is %d ", sum);
    return 0;
}
Output
kodingwindow@kw:~$ gcc kw.c
kodingwindow@kw:~$ ./a.out The addition of a given array is 261 kodingwindow@kw:~$
Advertisement