Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ Write a program that will take a 3x3 matrix and test to see if it is a magic square. A 3x3 matrix is

In C++ Write a program that will take a 3x3 matrix and test to see if it is a magic square. A 3x3 matrix is magic if all of the following sums are the same: each row, each column, and both diagonals.

The following example is a magic square because everything adds up to the same number (2+7+6=15, 9+5+1=15, 4+3+8=15, 2+9+4=15, 7+5+3=15, 6+1+8=15, 2+5+8=15, and 4+5+6=15).

2

7

6

9

5

1

4

3

8

Use functions dont put everything in main

Use loops to calculate the sums dont hardcode the calculation. For example, you dont want something like sum = matrix[0][0] + matrix[0][1] + matrix[0][2]. That is hard to update if we change the size of the array

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

Question Can a self-employed person adopt a money purchase plan?

Answered: 1 week ago