Access over 20 million homework & study documents
search

A simplified version of the matrix multiplication for 2x2 matrices c

Content type

User Generated

Rating

Showing Page:
1/4
A simplified version of the matrix multiplication for 2x2
matrices can be represented as: The answer to this
question should be a C program structured as a helper
(user-defined) function only (do not write the preprocessor
directives not the main program). Your function named
mult performs the 2x2 matrix multiplication and displays on
the screen the resulting matrix in conventional matrix
format (2 rows / 2 columns). All variables are integers. You
must use 2-D arrays only for this question and name them
mat1, mat2 and mat3. No other variables are permitted
(except i and j as loop control variables if needed). Do not
use dynamically allocated variables. Your function needs
to work only with 2x2 matrices. Penalties will be applied for
bad variable naming.
Solution
multi.c
#include <stdio.h>
void mult (int mt1[][2], int mat2[][2], int mat3[][2]);
int main()
{
int mat1[2][2], mat2[2][2], mat3[2][2],i,j;
/* Storing elements of first matrix. */
printf(\"\ Enter elements of matrix 1:\ \");
for(i=0; i<2; i++)

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/4
for(j=0; j<2; j++)
{
printf(\"Enter elements a %d %d: \",i ,j);
scanf(\"%d\",&mat1[i][j]);
}
/* Storing elements of second matrix. */
printf(\"\ Enter elements of matrix 2:\ \");
for(i=0; i<2; i++)
for(j=0; j<2; j++)
{
printf(\"Enter elements b%d%d: \",i ,j );
scanf(\"%d\",&mat2[i][j]);
}
/* Initializing elements of matrix mult to 0.*/
for(i=0; i<2; i++)
for(j=0; j<2; j++)
{
mat3[i][j]=0;
}
mult(mat1, mat2, mat3);
return 0;
}
void mult (int mat1[][2], int mat2[][2], int mat3[][2]){
int i,j,k;
/* Multiplying matrix a and b and storing in array mult. */

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/4

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 4 pages?
Access Now

Unformatted Attachment Preview

A simplified version of the matrix multiplication for 2x2 matrices can be represented as: The answer to this question should be a C program structured as a helper (user-defined) function only (do not write the preprocessor directives not the main program). Your function named mult performs the 2x2 matrix multiplication and displays on the screen the resulting matrix in conventional matrix format (2 rows / 2 columns). All variables are integers. You must use 2-D arrays only for this question and nam e them mat1, mat2 and mat3. No other variables are permitted (except i and j as loop control variables if needed). Do not use dynamically allocated variables. Your function needs to work only with 2x2 matrices. Penalties will be applied for bad variable naming. Solution multi.c #include void mult (int mt1[][2], int mat2[][2], int mat3[][2]); int main() { int mat1[2][2], mat2[2][2], mat3[2][2],i,j; /* Storing elements of first matrix. */ printf(\"\ Enter elements of matrix 1:\ \"); for(i=0; i ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Really great stuff, couldn't ask for more.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4