Professional Documents
Culture Documents
Jaypee Institute of Information Technology
Jaypee Institute of Information Technology
(Deemed to be University)
Enrollment ID 23203007
General Terminology
6) Special Rules
• If moving to a cell that is outside the grid, wrap around to
the opposite side.
• If moving to a cell already filled, move vertically down
instead.
• If moving to a cell outside both the rows and columns, stay
in the same column.
• Place the current number in the determined cell.
7) Repeat Until Grid is Full
• Continue placing numbers until all cells are filled.
Properties of Magic Squares
function generateDoublyEvenMagicSquare4x4():
Create a 4x4 grid with all elements initialized to 0
#include <stdio.h>
i = 0;
j = n / 2;
i--;
j++;
if (i < 0) {
i = n - 1;
}
if (j == n) {
j = 0;
}
if (magicSquare[i][j] != 0) {
i += 2;
j--;
if (i >= n) {
i -= n;
}
if (j < 0) {
j = n - 1;
}
}
}
}
int main() {
int n = 4; // Order of the magic square
int magicSquare[n][n];
generateMagicSquare(n, magicSquare);
return 0;
}
Conclusion
• Symmetry:
o Doubly even magic squares often display symmetry along
both axes (horizontal and vertical) and across the main
diagonals.
• Programmatic Construction:
o Constructing a doubly even magic square
programmatically involves a systematic approach to
ensure the required properties are satisfied. Common
algorithms include the Strachey method or the Siamese
method.
1. Order Validation:
- The program ensures that the order of the magic square is 4, as it
must be a multiple of 4 for it to be doubly even.
4. Structured Approach:
- The program employs a structured approach to construct the magic
square, following a systematic algorithmic procedure. This highlights
the mathematical elegance and regularity inherent in the construction
of doubly even magic squares.
5. User Interaction:
- The program prompts the user to input the order of the magic
square, providing flexibility for generating magic squares of different
orders (though the provided program is specifically designed for order
4).