fork download
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. int d;
  6. printf("Please input dimensions: (between 3 and 9, inclusive): \n");
  7. scanf("%i", &d);
  8.  
  9. int array[d][d];
  10.  
  11. int k = 1;
  12.  
  13. for (int i = 0; i < d; i++)
  14. {
  15. for (int j = 0; j < d; j++)
  16. {
  17. array[i][j] = (d * d) - k; //d^2 doesn't work to square a function
  18. k++;
  19. }
  20. }
  21.  
  22. for (int z = 0; z < d; z++)
  23. {
  24. for (int y = 0; y < d; y++)
  25. {
  26. printf("%i\n", array[z][y]);
  27. }
  28. }
  29.  
  30. printf("%i\n", array[0][0]);
  31. printf("%i\n", array[0][1]);
  32. }
  33.  
Success #stdin #stdout 0s 2164KB
stdin
3
stdout
Please input dimensions: (between 3 and 9, inclusive): 
8
7
6
5
4
3
2
1
0
8
7