#include <iostream> #include <iomanip> using namespace std; int main () { int si
ID: 3618409 • Letter: #
Question
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
int size;
int count(1);
int square[99][99];
int i, j;
int row,cols;
do
{
cout << "Enter size for magicsquare" << endl;
cin >> size;
}while(size>99 || size<0 || size%2==0);
cols=0;
cols=(size-1)/2;
row=0;
square[row][cols]=count;
count++;
while(count<=size*size)
{if(row-1<0)
i=size-1;
else
i=row-1;
if(cols-1<0)
j=size-1;
else
j=cols-1;
if(square[i][j]<0)
{
if(row+1==size)
i=0;
else
i=row+1;
}j=cols;
square[i][j]=count;
count++;
row=i;
cols=j;
}
return 0;
}
Explanation / Answer
Just add this code to your source code for(i =0 ;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.