Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A matrix in algebra is an array of numbers arranged in rows and columns. In C, it is common to implement Matrices using two dimensional

image text in transcribed

A matrix in algebra is an array of numbers arranged in rows and columns. In C, it is common to implement Matrices using two dimensional arrays. We will be focusing on manipulating a fixed size 5x5 square matrix (5 rows and 5 columns) Create a C program called matrix.c that implements multiple functions doing each a specific task. The functions that you have to implement are the following: 1. Write a function that will fill a 5x5 matrix by randomly generated numbers. You can use rand0 and srand0 functions provided by library to generate random numbers between 1 and 100. The signature of the function is void fillMatrix(int matrix[rowsl[cols); rows and cols are global constants defined as follow at the beginning of your c file: define rows 5 #define cols 5 The main0 function that will be used to test your functions is provided as follow int main() int matrix[rows][cols]; fillMatrix(matrix) 11Q1 printMatrix(matrix); II Q2 transposeMatrix(matrix) I/ 03 printMatrix(matrix); int matrix2[2] [cols]-,1,2,3,4,5,6,7,8,9 int matrixResult[rows] [cols]; multiplyMatrix(matrix2, matrix, resultMatrix) 11 04 printMatrix(matrixResult); return 0; 2. Write a function that given a 5x5 matrix as parameter, will print each row of the matrix to the screen line by line. The signature of the function is: void printMatrix(int matrix[rowsl[colsD; Use array notation in you r implementation. 3. In algebra, a transpose of a matrix is a matrix whose rows are the columns of the original. Write a function that will take a 5x5 matrix as parameter and then transpose it in-place which means without the use of an extra or a temporary matrix while transposing. The signature of the function is: void transposeMatrix(int matrix rowslIcols): Use pointer notation in your implementation. 4. Write a function that given three matrices as parameters (two as input matrices and one as output), will calculate the product of the first 2 matrices and place the result in the third one signature of the function is: void multiplyMatrix(int m1121lcols, int m2lrowsl[colsl, int resultMatrix[rowsl[cols) Note that the first matrix isn't 5x5. Extra with zero. resultMatrix will hold the result of the multiplication of ml X m2. Use pointer notation in your implementation. space in resultMatrix should be filled

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

Students also viewed these Databases questions