Answers for "1d array in c"

C
0

1d array in c

#include<stdio.h>

int main()
{
    int arr[5], i, s = 0;

    for(i = 0; i < 5; i++)
    {
        printf("Enter a[%d]: ", i);
        scanf("%d", &arr[i]);
    }

    for(i = 0; i < 5; i++)
    {
        s += arr[i];
    }

    printf("\nSum of elements = %d ", s);

    // signal to operating system program ran fine
    return 0;
}
Posted by: Guest on August-05-2021

Code answers related to "C"

Browse Popular Code Answers by Language