Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please Help!!! I don\'t know whereto begin. Anything will help! Magic Square and

ID: 3610862 • Letter: P

Question

Please Help!!! I don't know whereto begin. Anything will help! Magic Square andFormatting Program    Write a complete program togenerate and output to the screen an odd-order standard magicsquare between the sizes 3x3 and 17x17 using a suitable, readable,square-like format including row sums, column sums, and the twomain diagonal sums.
   In order to generate a square with columns ofnumbers, you will be required to use width control in your outputstatements.    Outputting your magic squareand sums to a text file as well as to the screen is worth bonuspoints provided the text file output resembles a square with itsassociated sums.    There isn't any input forthis program. You will use the function (below) to get a randomsize if the flag is true and a fixed size of 7 if the flag isfalse. During development of your program, it is easier to trackdown mis-behaving code if the square size is constant. Certainlogic errors are masked in the 3x3 magic square, hence the use of a7x7 for testing. Function: int size(bool flag) {       inttest;       if(flag)       {             do             {                   test= (int)(double(rand())/double(RAND_MAX) * 14.0 + 3.0);             }while(test% 2 == 0);      //i.e. it's even, tryagain             returntest;       }       else             return7; } Please Help!!! I don't know whereto begin. Anything will help! Magic Square andFormatting Program    Write a complete program togenerate and output to the screen an odd-order standard magicsquare between the sizes 3x3 and 17x17 using a suitable, readable,square-like format including row sums, column sums, and the twomain diagonal sums.
   In order to generate a square with columns ofnumbers, you will be required to use width control in your outputstatements.    Outputting your magic squareand sums to a text file as well as to the screen is worth bonuspoints provided the text file output resembles a square with itsassociated sums.    There isn't any input forthis program. You will use the function (below) to get a randomsize if the flag is true and a fixed size of 7 if the flag isfalse. During development of your program, it is easier to trackdown mis-behaving code if the square size is constant. Certainlogic errors are masked in the 3x3 magic square, hence the use of a7x7 for testing. Function: int size(bool flag) {       inttest;       if(flag)       {             do             {                   test= (int)(double(rand())/double(RAND_MAX) * 14.0 + 3.0);             }while(test% 2 == 0);      //i.e. it's even, tryagain             returntest;       }       else             return7; } }

Explanation / Answer

please rate - thanks please note-the function you provided always returns 3. therandom number generator is not seeded #include #include int size(bool flag); int main() {             int a[20][20],x=0,y,n,i,j,k=1,row=0,col[20]={0},diag1=0,diag2=0;              bool flag=true;             n=size(flag);             for(i=0;i