- #1
- 76
- 0
C programming help nedded ??what is the wrong of this code?
#include<stdio.h>
int matA[3][4],matB[4][3],matAB[3][3],i,j,k;
void read();
void multiply();
void display();
int main()
{
read();
multiply();
display();
return 0;
}
void read()
{
printf("Enter your matrix A:\n");
for (i=0;i<3;i++)
{
for (j=0;j<4;j++)
{
scanf("%d",&matA[j]);
}}
printf("Enter your matrix B:\n");
for (i=0;i<4;i++)
{
for (j=0;j<3;j++)
{
scanf("%d",&matB[j]);
}}
}
void multiply()
{
for (i=0;i<3;i++)
{
for (j=0;j<3;j++)
{
matAB[j]=0;
for (k=0;k<4;k++)
{
matAB[j]=matAB[j]+matA[k]*matB[k][j];
}}}}
void display()
{
printf("Here is your multiplied matrix:\n");
for (i=0;i<3;i++);
{
for (j=0;j<3;j++);
{
printf("%d",matAB[j]);
}
printf("\n");
}}
i wrote this multiply matA 3*4 by matB 4*3 ...its compiling but doesn't give me the required output??/it gives me a 0...i don't know how to find the error ...im totally stuck can someone please check this code and find the error for me ...
#include<stdio.h>
int matA[3][4],matB[4][3],matAB[3][3],i,j,k;
void read();
void multiply();
void display();
int main()
{
read();
multiply();
display();
return 0;
}
void read()
{
printf("Enter your matrix A:\n");
for (i=0;i<3;i++)
{
for (j=0;j<4;j++)
{
scanf("%d",&matA[j]);
}}
printf("Enter your matrix B:\n");
for (i=0;i<4;i++)
{
for (j=0;j<3;j++)
{
scanf("%d",&matB[j]);
}}
}
void multiply()
{
for (i=0;i<3;i++)
{
for (j=0;j<3;j++)
{
matAB[j]=0;
for (k=0;k<4;k++)
{
matAB[j]=matAB[j]+matA[k]*matB[k][j];
}}}}
void display()
{
printf("Here is your multiplied matrix:\n");
for (i=0;i<3;i++);
{
for (j=0;j<3;j++);
{
printf("%d",matAB[j]);
}
printf("\n");
}}
i wrote this multiply matA 3*4 by matB 4*3 ...its compiling but doesn't give me the required output??/it gives me a 0...i don't know how to find the error ...im totally stuck can someone please check this code and find the error for me ...