I'm confused with declaring arrays. If I enter a size, ie good[200], the answer will just return 200.
The program essentially takes 10 integers from user and returns which are of particular ranges of numbers. I thought of doing that by collecting the numbers through arrays and then returning the length of those arrays as the answer.
int n[10], i, j, excellent[], good[], poor[];
printf("Input 10 integers\n");
for (i = 0; i < 10; i++) {
scanf("%d", &n[i]);
}
for (j = 0; j < 10; j++) {
if (n[j] > 80) {
excellent[j] = n[j];
}
if (n[j] >= 60 && n[j] <= 79) {
good[j] = n[j];
}
if (n[j] < 60) {
poor[j] = n[j];
}
}
printf("%lu are excellent\n", (sizeof(excellent) / sizeof(excellent[0])));
printf("%lu are good\n", (sizeof(good) / sizeof(good[0])));
printf("%lu are poor\n", (sizeof(poor) / sizeof(poor[0])));
excellent[], good[],poor[]array size missing refers to those. You need to give it a size either explicitly or via an initializer.good[200]. The size will then be 200 elements. If you want to show how many you've actually used, you'll have to keep track of that separately.int excellent[10],good[10],poor[10];?