Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer question 1 and 2 A matrix in algebra is an array of numbers arranged in rows and columns. In C, it is common

image text in transcribed

image text in transcribed

Please answer question 1 and 2

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 rand) and srand) functions provided by library to generate random numbers between 1 and 100. The signature of the function is: void fillMatrix(int matrix[rows][cols]); rows and cols are global constants defined as follow at the beginning of your c file: #define rows 5 #define cols 5 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[rows][cols]); Use array notation in your 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 thern 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[rows][cols]); 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. The signature of the function is: void multiplyMatrix(int m1[2][cols], int m2[rows][cols], int resultMatrix[rows][cols]) Note that the first matrix isn't 5x5. Extra space in resultMatrix should be filled with zero. resultMatrix will hold the result of the multiplication of ml Xm2 Use pointer notation in your implementation The main) function that will be used to test your functions is provided as follow: int main() int matrix[rows][cols] fillMatrix(matrix); 1/Qi printMatrix(matrix); // 02 transposeMatrix(matrix); 3 printMatrix(matrix); int matrix2[2][cols]-(e,1,2,3,4,5,6,7,8,93; int matrixResult[rows] [cols]; multiplyMatrix(matrix2, matrix, resultMatrix); // Q4 printMatrix(matrixResult); return e

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

Compare and contrast a Sec. 2503(c) trust and aCrummeytrust.

Answered: 1 week ago

Question

d. How were you expected to contribute to family life?

Answered: 1 week ago