Question: PLease complete code in C. Complete the methods to generate a magic square from user input. A magic square is a matrix of size n

PLease complete code in C.

Complete the methods to generate a magic square from user input. A magic square is a matrix of size n x n with positive numbers from 1 n2 arranged such that the numbers in any line (horizontal, vertical, and both main diagonals) sum to the same values.

#include #include #include

// mag square struct typedef struct { int size; int **square; } MagSquare;

/* TODO: Get size input from user, must be odd */ int getSize() { int size; return 0; }

/* TODO: * Makes a magic square of size n * returns a pointer to the completed MagSquare struct. */ MagSquare* createSquare(int n) {

return 0; }

/* TODO: * Generates a magic square of the user specified size and * output the square */ int main(int argc, char *argv[]) {

// TODO: Get magic square's size from user

// TODO: Generate the magic square

// TODO: Output the magic square

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!