1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 | #include <stdio.h>
#include <stdlib.h>
void mult(int [][3],int [][3],int [][3]);
//Program for Multiplication of matrix 3*3 Time and Update
int main()
{
int a[3][3],b[3][3],c[3][3];
int i,j;
printf("Enter value of matrix A \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
printf("\n");
}
printf("Enter value of matrix B \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
scanf("%d",&b[i][j]);
printf("\n");
}
mult (a,b,c);
printf("https://timeandupdate.com \n");
printf("The Multiplication is :-\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
printf("%d\t",c[i][j]);
printf("\n");
}
return 0;
}
void mult(int x[][3],int y[][3],int z[][3])
{
int i,j,tmp1=0,tmp2=0,tmp3=0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
tmp1=x[i][j]*y[j][0]+tmp1;
tmp2=x[i][j]*y[j][1]+tmp2;
tmp3=x[i][j]*y[j][2]+tmp3;
}
z[i][0]=tmp1;
z[i][1]=tmp2;
z[i][2]=tmp3;
}
}
|
Here is the Output:
I did not check all but looks its correct. |
The above program is compiled and successfully run on Code::Block 13.12.
This is easy program but you just need to focus. If you cant understand how this program flow don't forget to comment we will be back to help you.
0 comments:
Post a Comment