# Print Magic Square Matrix C Program

By | November 3, 2016

Let us learn how to print or generate magic square matrix in C programming language. A magic square is actually a multi – dimensional matrix.

#### What is a Magic Square Matrix?

A magic square is a matrix, which consists of an arrangement of distinct non – repeating integers in a Matrix form, where the sum of the every row, column, major and minor diagonals is same.

This sum is, therefore, called as a Magic Constant. A magic square has the same number of rows and columns.

Normally, magic squares work only for odd integers. However, you can modify the c program to print the magic square of even numbers too.

#### Example of Magic Square

4 9 2
3 5 7
8 1 6

Sum of Rows = 15

Sum of Columns = 15

Sum of Major Diagonal = 15

Sum of Minor Diagonal = 15

#### Output

If you have any doubts or compilation errors in this C program to display magic square, let us know about it in the comment section below.

## 2 thoughts on “Print Magic Square Matrix C Program”

1. Pankaj Vidhate

Is there any kind of similarity between Magic Number and Magic Square Matrix?