Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3.1.5 Matrix transpose Matrix transpose is the operation consisting in swapping the rows of a matrix for its columns. It is a basic matrix operation

3.1.5 Matrix transpose

Matrix transpose is the operation consisting in swapping the rows of a matrix for its columns. It is a basic matrix operation used in many real-life applications such as image processing, signal modulation, etc.

For example, here is a matrix and its transpose:

Write program matrix_transpose.c that receives a matrix inputted by the user and displays the matrixs transpose, as illustrated in the following example.

$ ./matrix_transpose 4 1 2 3 4 5 6 7 8 9 1 2 3 7 2 9 3 Matrix is: 1 2 3 4 5 6 7 8 9 1 2 3 7 2 9 3 After transpose, matrix is: 1 5 9 7 2 6 1 2 3 7 2 9 4 8 3 3 $ ./matrix_transpose 11 Invalid count $ ./matrix_transpose 2 a Invalid matrix input $ echo $? 1 $ 

The maximum size of the matrix is 10x10. There is no dynamic memory allocation for this problem, you can just define a matrix of the maximum size.

Your program should define four functions:

A function that can print a matrix. Each number should be printed on 4 digits. The prototype should be: void matrix_print(int matrix[][MAX_COUNT], int count).

A function that can transpose a matrix in place (meaning that you should not create a new matrix, but modify the existing one). Its prototype should be void matrix_transpose(int matrix[][MAX_COUNT], int count).

A function that gets the size of the matrix and the values composing the matrix from the user. If the size is negative or greater than the maximum size, or if one of the inputted data values is incorrect, the function should display the corresponding error message and return 1. If the function is successful, it should return 0. Its prototype should be int matrix_get(int matrix[][MAX_COUNT], int *count).

The main function should be the function defining the matrix. It should gets the matrixs values filled out by matrix_get() and quit if the input failed. Otherwise, it should print the matrix before and after its transposition.

include comments if possible showing how the code works

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions