Starting from:

$30

IT210- Programming Assignment 2 Solved

Your program should expect to read 16 integers using input, each entered on a separate line and no sentinel is required since we know we will read 16 integers. Print the resulting 4x4 matrix. The values you read go across the first row, then the second row, etc. Two sample runs are shown below. Your output should look identical to this. Note that the prompts below use the string formatting operator to generate the changing string. I will test your program with different squares (some magic, some not) to verify that you have performed all the necessary tests to verify that the square is magic.



Enter a value for location Enter a value for location Enter a value for location Enter a value for location Enter a value for location Enter a value for location Enter a value for location Enter a value for location Enter a value for location Enter a value for location Enter a value for location Enter a value for location Enter a value for location Enter a value for location Enter a value for location Enter a value for location
 


(0,0):
1
Enter a
(0,1):
12
Enter a
(0,2):
8
Enter a
(0,3):
13
Enter a
(1,0):
14
Enter a
(1,1):
7
Enter a
(1,2):
11
Enter a
(1,3):
2
Enter a
(2,0):
15
Enter a
(2,1):
6
Enter a
(2,2):
10
Enter a
(2,3):
3
Enter a
(3,0):
4
Enter a
(3,1):
9
Enter a
(3,2):
5
Enter a
(3,3):
16
Enter a
 
 


value for location (0,0): 4 value for location (0,1): 15 value for location (0,2): 14 value for location (0,3): 1 value for location (1,0): 16 value for location (1,1): 3 value for location (1,2): 2 value for location (1,3): 13 value for location (2,0): 5 value for location (2,1): 10 value for location (2,2): 11 value for location (2,3): 8 value for location (3,0): 9 value for location (3,1): 6 value for location (3,2): 7 value for location (3,3): 12
 

1
12
8
13
4
15 14   1
14
7
11
2
16
3    2 13
15
6
10
3
5
10 11   8
4
9
5
16
9
6    7 12
It is a magic square.
It
is not a magic square.
 

More products