0

I am working on a project using 2D arrays ( I have never really understood the use, I know how they work, just have always had problems implementing) that holds a 4x4 "magic square." Magic squares contain unique numbers whose rows, columns, and major diagonals add up to the magical value (34 in the case of this program). It is to allow the user to input the values and then checks the user's square.

Anyway, I am getting the error "cannot convert 'int (*)[((unsigned int)((int)colNum))]' to 'int (*)[4]' for argument '1' to 'bool checkRows(int (*)[4], int, int)' "

NOTE: This is not the complete program, just a snippet as I am just trying to work one function at a time.

Any help is always helpful.

```
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
bool checkRows ( int theSquare[][4], const int numRows, const int magicValue );
bool checkColumns ( int theSquare[][4], int const numRows, const int magicValue);
bool checkDiagonals (int theSquare[][4], const int numRows, const int magicValue);
bool checkRange ( int theSquare[][4], const int numRows, const int magicValue);
int main()
{
int magicValue = 34;
int rowNum = 0;
int colNum = 0;
int numRows = 0;
int theSquare[rowNum][colNum];
for ( int rowNum = 0; rowNum <= 4; rowNum++ )
{
for ( int colNum = 0; rowNum <= 4; colNum++ )
{
theSquare[rowNum][colNum] = 0;
}
}
cout << "\nThe magic value for your square is " << magicValue << ", which "
<< "means that every row, column and diagonal of your square must add "
<< "up to that number.\n\n";
for ( int rowNum = 0; rowNum < 4; rowNum++ )
{
cout << "Please enter the 4 values for row " << rowNum << ", "
<< "seperated by spaces: ";
cin >> theSquare[rowNum][0] >> theSquare[rowNum][1]
>> theSquare[rowNum][2] >> theSquare[rowNum][3];
theSquare[rowNum][4] = theSquare[rowNum][0] + theSquare[rowNum][1] +
theSquare[rowNum][2] + theSquare[rowNum][3];
numRows = numRows + 1;
}
checkRows ( theSquare, numRows, magicValue );
return 0;
}
bool checkRows ( int theSquare[rowNum][4], const int numRows, const int magicValue )
{
int counter = 0;
cout << "ROWS: "
for ( int rowNum = 0; rowNum < 4; rowNum++ )
{
if ( theSquare[rowNum][4] == magicValue )
{
counter =+ 1;
}
else
{
cout << " " << rowNum;
}
}
if ( counter == 4 )
}
```