I'm sure that this is late, but I just wanted to let you know I was facing the same issue, and this was the solution I came up with. I couldn't achieve this using an actual array [] so had to make a manual work around.
#include<stdio.h>
int main(void)
{
//set variables
int a, b, i, sum = 0, avg;
//how many scores to average?
printf("How many scores do you want to average?: ");
scanf("%d", &a);
//collect scores
for (i = 0; i < a; i++)
{
printf("Enter scores: ");
scanf("%d", &b);
sum = sum + b;
}
// print sum
printf("The Sum of your array = %d \n", sum);
//results
avg = sum / a;
printf("The Average of your array = %d", avg);
}
I'm new to coding so forgive me if this is full of extra unnecessary fluff, but with this code, you can get the users input to determine the "array length", and it also asks the user to fill in those arrays and displays the total sum of all the values along with the average.