Question: Write a program that uses a 4 X 4 array and randomly place each integer from 1 to 16 into the 16 squares. The program

Write a program that uses a 4 X 4 array and randomly place each integer from 1 to 16 into the 16 squares. The program calculates the magic number by adding all the numbers in the array and then dividing the sum by 4. The 4 X 4 array is a magic square if the sum of each row, each column and each diagonal is equal to the magic number. Your program must contain at least the following functions :
a) a function to randomly fill the array with the numbers
b) a function to determine if the array is a magic square
Run these functions for 10000 number of times and print the number of times the array is a magic square.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!