Ive got this homework to do concerning magic squares. Could anyone help me out on the C++ code for this problem?
An n by n matrix that is filled with the numbers 1, 2, 3, ... n*n is a Magic Square if the sum of the elements in each row, in each column and in the two diagonals is the same value. For example
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
is a Magic Square. Write a program that reads n from the user and then prompts for n*n values, ensuring that each is between 1 and n*n.
:Check that each number occurs only once
:Check if the sums of the rows, columns and diagonals are equal
isplay the square on the screen
Based on these facts, inform the user whether the numbers form a Magic Square or not.
You must use 2-Dimensional static arrays! Use a 4x4 array.