#include #include #include int** doublyEvenMagicSquare(int n) { int bits = 38505; int size = n * n; int mult = n / 4,i,r,c,bitPos; int** result = (int**)malloc(n*sizeof(int*)); for(i=0;i=10){ n /= 10; count++; } return count; } void printMagicSquare(int** square,int rows){ int i,j,baseWidth = numDigits(rows*rows) + 3; printf("Doubly Magic Square of Order : %d and Magic Constant : %d\n\n",rows,(rows * rows + 1) * rows / 2); for(i=0;i= 4, e.g. 4, 8, 12) for the order of the magic square: "); scanf("%d", &n); if (n < 4 || n % 4 != 0) printf("Please enter doubly even number greater than or equal to 4 for the order of the magic square.\n"); } while (n < 4 || n % 4 != 0); //version one (a bit complicated, but still study it) printMagicSquare(doublyEvenMagicSquare(n),n); printf("\n\n"); return 0; }