# CIS 270 Lab 3

Points: **30** Due Date: **Thursday August 7, 2003**
A Magic Square is an array of numbers that has this property:
If you add the numbers of any row, column or diagonal, they are all equal.
You need to verify that this property is true of a given square.
For example,

16 | 3 | 2 | 13 |

5 | 10 | 11 | 8 |

9 | 6 | 7 | 12 |

4 | 15 | 14 | 1 |

The sum of each row is 34, the sum of each column is 34 and
the sum of each diagonal is 34.

The simplest way to get the data into the program is by using
an initializer on the array.
Since a 2 dimensional array is really a one dimensional
array where each element in the array, each cell, is a one
dimensional array, we can intialize it like this.

int data[SIZE][SIZE] = {
{16,3,2,13},
{5,10,11,8},
{9,6,7,12},
{4,15,14,1},
};

You should be able to copy and paste the above code into your program
and save a lot of typing.
The output should consist of a printout of the array, the sum and an
statement that it is correct or not.
To test the program, run it once with the data as defined above.
It should say that the square is magic.
Then change one of the numbers above and re-compile it.
This time when you run it, it should say it isn't magic.

Here is an idea of what the output might look like.
Yours doesn't have to be exactly like this.
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
The square is Magic and the sum is 34
Press any key to continue

## Deliverables:

You should turn in a listing of the program. Staple
the cover
sheet to that.

## Notes

Think about how you will do this so you can ask questions.

**ASK** if you have any questions.