im doing the CS50. They discuss functions.
#include <cs50.h>
#include <stdio.h>
const int array_length = 3;
float average(int length, int array[]);
int main(void)
{
int scores[array_length];
for (int i = 0; i < array_length; i++)
{
scores[i] = get_int("Score: ");
}
printf("Average: %f\n", average(array_length, scores));
}
float average(int length, int array[])
{
int sum = 0;
for (int i = 0; i < length; i++)
{
sum += array[i];
}
return sum / (float) length;
}
In the function they declaring the "length" variable. But why they do not assign a value to it? How C knows the "length" is 3 ?