Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

project input file: In this project a matrix (two dimensional array) will be def

ID: 3565614 • Letter: P

Question

project input file:

In this project a matrix (two dimensional array) will be defined as a pointer to a data structure containing 2 integers giving the number of rows and number of columns of the matrix followed by an integer array containing the values of the matrix. This could described in C as: you must create a procedure, print matrix, that will be no return value. The output should look like the table below: The actual number of row and columns must match the size of the input matrix. You must create a procedure, multiply matrix that will multiply the two matrices forming C = A X B. Pointer to the input matrix A will be be in a 0, pointer to the input matrix B will be in $a1, pointer to sufficient sapce for matrix C will be in $a2. The procedure must test to ensure the matrices can be legally multiplied. if not, a NULL value is returned in $v0, if legal, the pointer to C is returned in $v0, the correct number of rows and columns is placed in C and the multiplication is performed and the results placed in the C data area.

Explanation / Answer

The below is the code to multiply 2 matrices of any dimension I:e only possible ones...and it prints the resulting matrix.....

so now all you have to do is to make your structure according to the output matrix declared in the code.

That's all ...Njoy !!

Source Code :

#include<stdio.h>

#include<stdlib.h>

int main(void)

{

int a[10][10],b[10][10],c[10][10],n=0,m=0,i=0,j=0,p=0,q=0,k=0;

    int *pt,*pt1,*pt2;

printf("Enter size of 1st 2d array : ");

scanf("%d %d",&n,&m);

    for(i=0;i<n;i++)

{

        for(j=0;j<m;j++)

            {

            printf("Enter element no. %d %d :",i,j);

scanf("%d",&a[i][j]);

}

}

printf("Enter size of 2nd 2d array : ");

    scanf("%d %d",&p,&q);

for(i=0;i<p;i++)

{

for(j=0;j<q;j++)

            {

printf("Enter element no. %d %d :",i,j);

scanf("%d",&b[i][j]);

        }

}

if(m!=p)

        {

printf("Multiplication cannot be done ");

exit (0);

}

pt=&a[0][0];

pt1=&b[0][0];

    pt2=&c[0][0];

for(i=0;i<n;i++)

        {

        for(k=0;k<q;k++)

            {

            *(pt2+(i*10+k))=0;

            for(j=0;j<m;j++)

{

*(pt2+(i*10+k))+=*(pt+(i*10+j))**(pt1+(j*10+k));

            }

}

}

for(i=0;i<n;i++)

        {

for(j=0;j<q;j++)

            {

            printf("%d ",c[i][j]);

        }

printf(" ");

}

return 0;

}