Question: FOLLOW ALL DIRECTIONS. Compile a source code in c++. Use data provided in attachments. Lab 11 - Is This Box a Magic Box? Objectives Make
Lab 11 - Is This Box a Magic Box? Objectives Make use of a 2D Array Understand how to traverse a 2D Array Instructions: A magic square is a matrix (two dimensional arrays) in which the sum of each row, sum of each column, sum of the mairn diagonal, and sum of the reverse diagonal are all the same value You are to code a program to determine if a given two- dimensional array (that will be read in from a file) is a magic square or not. This task (the task of determining if the square is magic) will be run in a loop. This loop should continue to read in squares, and determine if they are magic until the size read in is equal to -1 (the sentinel value) Code a function/method for each of the following: . Read data into the matrix Print the matrix on the screen Sum a row given the index for that row Sum a column given the index for that column Sum the main diagonal . Sum the reverse diagonal Determine if the 2D Array is a magic square The main method will read the size of the array outside of the main loop. Then inside the main loop it will call methods to read the data into the matrix, print the matrix, print all the rovw sums, print al the column sums, and print both diagonals. Then the program will determine if the matrix is a magic square and print an appropriate message. The next size should be read in before the loop repeats. The main should continue on with the next matrix, until a size of-1 is reached
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
