I'm a bit new in C and I'm trying to write some simple code that gets some grades for a few students and store them in a two-dimensional array. The problem is it won't run because the array is not declared. Why do I need to declare something before I can use it and how can I simply declare it without running through the whole loop and declaring some value?
This is my code for now:
#include <stdio.h>
int main()
{
int students = 2, courses = 2;
int grades[students][courses];
for(int i=0; i<students; i++)
{
for(int j=0; j<courses; j++)
{
printf("Student %d, course %d grade: ", i, j);
scanf("%d", &grades[i][j]);
}
}
}