What's new

Help C Arrays

velvetred

Eternal Poster
Joined
May 4, 2022
Posts
709
Solutions
18
Reaction
1,253
Points
416
Explain the solution of this program

C:
#include <stdio.h>
#define aSize 100

int main()
{
    int arr[aSize];
    int i, n, sum=0;

    
    printf("Enter size of the array: ");
    scanf("%d", &n);
    printf("\nEnter %d elements in the array: \n", n);
    for(i=0; i<n; i++)
    {
        printf("\nEnter %d element in the array: ", i+1);
        scanf("%d", &arr[i]);
    }

  
    for(i=0; i<n; i++)
    {
        sum = sum + arr[i];
    }

    printf("\nSum of all elements of array = %d \n", sum);

    return 0;
}
 

Similar threads

Back
Top