Try this:
Code:
#include <iostream.h>
#include <iomanip>
#include <math>
using std::cout;
using std::cin;
using std::endl;
const int n = 4;
bool checkrows (int thesquare[][n], int row_num, int magicvalue);
int main()
{
int a[n][n],j,x,y;
for ( int b = 0; b < n; b++ )
{
cout << "Enter the 4 values for row " << b + 1 << ", separated by space: ";
for (int c = 0; c < n; c++)
cin >> a[b][c];
}
cout << "Hmmm.... is it a magic square? Let's see...." << endl;
cout << "Checking rows ... " << endl;
for ( int d = 0; d < n; d++ )
{
if ( checkrows( a, d, j) == false )
cout << setw( 8 ) << "Eek! Row " << d+1 << " does not add up to the magic value!";
}
for ( x = 0; x < n; x++ )
{
cout <<"Here is row " << x+1 << ":";
for ( y = 0; y < n; y++ )
cout << a[x][y] << " ";
cout << endl;
}
return 0;
}
bool checkrows (int thesquare[][n], int row_num, int magicvalue)
{
int l, m, o, p;
m = 0;
for ( l = 0; l < n; l++ )
{
m += thesquare[row_num][l];
if ( m != (n*(pow(n,2)+1)/2))
return false;
else
return true;
}
}
It doesn't appear you need the last parameter of function checkrows(), unless this is something you are adding later.