1. Engineering
  2. Computer Science
  3. need this to be done in c programming use...

Question: need this to be done in c programming use...

Question details

Need this to be done in C programming !!!

Use the code skeleton on the next page to write a C program that allows the user to create any square matrix (a 2D arrays with the same number of rows and columns), for instance, a square matrix of size 5 is a 2d array of 5 rows and 5 columns. Your main program should:

  1. Allow the user to set the size (order) of the square matrix

  2. Set the values of the matrix

  3. Print the square matrix on the screen in a tabular format

  4. Check and print if the square matrix is a magic square or not.

  5. Check and print if the square matrix is a distinct matrix or not.

  6. Sort the square matrix using row-wise approach.

  7. Calculate the transpose matrix for the square matrix

Can you please provide complete main code as well

The following is the code skeleton :

#include <stdio.h>
#define MAX 100

void setMatrixData(int numOfRows, int mat[][numOfRows]){
    // provide the implementation
}

void printMatrixData(int numOfRows, int mat[][numOfRows]){
    // provide the implementation
}

int isMagicSquare(int numOfRows, int mat[][numOfRows]){
    // provide the implementation
    return 1; // if the matrix is a magic square
}

int isDistinctSquare(int numOfRows, int mat[][numOfRows]){
    // provide the implementation
    return 1; // if the matrix has no duplicates all values are unique
}


void SortRowWise(int numOfRows, int mat[][numOfRows]){
    // provide the implementation
}


void GetTranspose(int numOfRows, int mat[][numOfRows], int tran[][numOfRows]){
    // provide the implementation
}



int main()
{
    int matrix[MAX][MAX];
    int transpose[MAX][MAX];

    int numOfRows;

    printf("Done...");
}

A row-wise sorting for a matrix is to short each row in the input matrix in ascending order, for example, given the following:

-1 -4

The output will be the following a row-wise sorted matrix

9-9-8-7 1 1 1

Given a square matrix, the ‚Äčtranspose of the matrix is a new matrix whose rows are the columns of the original. (This makes the columns of the new matrix the rows of the original). Here is a matrix and its transpose:

71 8 5 9-6 1 1 Original Matrix Transpose Matrix

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution