Question: Please ensure that the program is in C not C++. Also, this is to include a header file as well as two other c files.

Please ensure that the program is in C not C++.

Also, this is to include a header file as well as two other c files. Please indicate what portion goes into each file type

Write a C program to solve the following problem. The zip file should contain three source code files: main.c, matrix.c, and matrix.h

Problem Statement

Create a set of programs that perform the following matrix operations:

Fill matrix with random values in the range [low, high]

Print the matrix

Matrix addition

Matrix subtraction

Matrix multiplication

Matrix transpose

The matrix functions should be defined in the file matrix.c. The function prototypes should be declared in the file matrix.h. The main.c file will control program flow, and call functions as needed.

Preprocessor Directives, Global Constants

No preprocessor directives, other than #include are allowed for this assignment. No global constants or global variables are allowed for this assignment. You may declare constants, but must do so inside the main function.

Input

Create three 2D integer arrays. The array data type is int. The arrays do not need to be initialized. In the main function, create constants for the array rows and sizes.

Example: const int AROWS = 5; const int ACOLS = 3; const int BROWS = AROWS; const int BCOLS = ACOLS; const int CROWS = 3; const int CCOLS = 5;

You may create other constants, if needed.

Fill each of the three arrays with random numbers in the range [-9, 9]. These arrays will be used to test the matrix operations. Note that you will need to create other 2D arrays to store the results of calculations.

When submitting your final, working program, seed the random number generator with time(NULL). The srand function should be called only once, in the main function.

Output

The program output should closely resemble the example output shown below, in terms of format. Your numbers will be different, as the seeded random number generator will produce different values.

Please ensure that the program is in C not C++. Also, this

Matrix Operations

For each of the operations below, you will need to create a separate function. Fill matrix with random values in the range [low, high]

o Description: fill the matrix with random values in the range [low, high] o Input: matrix rows, matrix cols, high, low, o Output: matrix filled with random values o Return type: void

Print the matrix o Description: print the matrix, one row per line o Input: matrix, rows, cols

o Return type: void Matrix addition

o Description: C = A + B Add matrix A plus matrix B and store the result in matrix C

o Input: matrix A, B, rows, cols o Output: Matrix C contains the sum of A + B o Return type: void

Matrix subtraction o Description: C = A B

o Input: matrix A, matrix B, rows, cols

o Ouptut: matrix C contains the result of A - B Matrix multiplication

o Description: C = A x B Performs matrix multiplication

o Input: matrix A, B, rows, cols o Output: C contains the result of A x B o Return type void

Matrix transpose o Description: create the transpose of the input source matrix. Do not change the data in

the source matrix. o Input: source matrix, rows, cols o Output: transpose matrix o Return type void

Matrix A 72 -3 3-9 3 -7 Matrix -22 MatrixC 7-2 B -5-49 A + B Matrix D 1 12 1 4-9 -9 5 -10 6 -2 Matrix A-B -1142 -114-1 -12 -12 -9 1 4 Matrix F .AxC -129-102 -33 48 -26 -65 -2 -21-4-66 48 102 18 -84-90 55 94396-25 13 342444 Matrix G is transpose of A 8 27 6 0-44

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!