I'm new to C and I'm trying to master the basics so I've written a program which gives you the mean of tree numbers and it works, but when I try to write a more general version of it, as output I receive: Insert a series of numbers: "The mean of the numbers is -nan". Which means that I can not even insert the numbers. I don't now how to write the scanf part in a better way.
Here's the code:
#include <stdio.h>
int main() {
    int p;
    double n[p];
    int i;
    double sum = 0;
    double m;
    printf("Insert a series of numbers:\n");
    for(int r = 0; r < p; r++) {
        scanf("%lf", &n[r]);
    }
    for(i = 0; i < p; i++) {
        sum += n[i];
    }
    m = sum / p;
    printf("The mean of the numbers is %lf", m);
    return 0;
}
 
    