I have to write a program which checks the conditions of this specific 2D array:
const int Size = 3;
int a[][Size] = { { 4, 9, 2 }, { 3, 5, 7 }, { 8, 1, 6 } };
This is a magic square, as each row, col, and diagonal sum equals 15.
However, my program says that it is not a magic square, so there is an issue in the condition check.
for( int x = 0; x != Size; ++x ){
for( int y = 0; y != Size; ++y ){
condition += whatever[x][y];
}
if( condition != magicSum ) returnfalse;
condition = 0;
}
//if you get here, it means you have a magic strand or whatever you call it
It should be quite obvious what part of your code you have to make changes to.