In this code, I scanf to get the NxN array size. Then I try to create an array of that size, then make it a zero matrix. Any clues?
Code:
#include <stdio.h>
#include <math.h>
int main (){
/* Create a matrix of NxN dimensions */
int i, j, k;
printf("\nWhat NxN size of array do you want?\n");
printf("N=");
scanf("%d",&k);
getchar();
printf("You desire a %dx%d Matrix.\n" ,k,k);
/* Create a NxN matrix */
/* Array is now an NxN matrix. */
/* */
/* Display the matrix */
int M[k][k];
for (i=0; i<k; i++){
for (j=0;j<k;j++)
M[i][j]=0;
}
printf("\nHere is a zero array with the specified dimension %dx%d." , k,k);
for (i=0; i<k; i++){
for (j=0;j<k;j++)
printf("%f", M[i][j]);
printf("\n");
}
getchar();
return 0;
}