This preview shows pages 1–2. Sign up to view the full content.
COP 3275 Programming Using C Language
Fall 2011, Programming Assignment #5
Yi Wang
Radhika Medury
Min Chen
yiwan@cise.ufl.edu
rmedury@cise.ufl.edu
min@cise.ufl.edu
Due Date:
Wed. Dec 07, 2011 @ 12:00pm (noon)
NO
Late submission is accepted!
Problem description:
Write a program that prints an nxn matrix square (a square arrangement of the numbers
1,2,…n^2 in which the sum of the rows ,columns, and diagonals are all the same). The user
will specify the value of n:
This program creates a magic square of a specified size. The size must be an odd number
between 1 and 99.
Enter size of magic square : 5
17
24 1
8 15
23
5
7
14 16
4
6
13 20 22
10 12 19 21 3
11 18 25
2
9
Store the magic square in a two dimensional array. Start by placing the number 1 in the
middle of row 0.Place each of the remaining numbers 2,3,…n^2 by moving up one row and
over one column. Any attempt to go outside the bounds of the array should “wrap around” to
the opposite side of the array. For example, instead of storing the next number in row 1, we
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
 Fall '11
 JonathanLiu

Click to edit the document details