My program is designed to take a userinput for a square matrix - i want them to be able to enter each element as it would appear in the matrix. Instead, the program only takes one input and then loops infintely.
int main()
{
int dim;
printf("Input size of square matrix: ");
scanf("%d", &dim);
int mat[dim*dim];
printf("Input elements row by row: \n");
int p;
int q;
for (p = 0; p < dim; p++)
{
for (q = 0; q < dim; q++)
{
scanf(" %d", mat[dim*p + q]);
}
printf("\n");
}
return 0;
}