I attached the program and the output in this mail...
In output c[0][1] value is coming .... I dont know why...?
Attached File(s)
-
matrix_mul.txt (1.15K)
Number of downloads: 30 -
mat_mul_output.txt (535bytes)
Number of downloads: 21




Posted 18 March 2013 - 04:38 AM
matrix_mul.txt (1.15K)
mat_mul_output.txt (535bytes)
Posted 18 March 2013 - 07:44 AM
#include<stdio.h>
int main()
{
int i,j,x,y,z,p,q,m,n;
float a[3][3],b[3][3],c[3][3];
printf("\n Enter the row and column ");
scanf("%d %d",&x,&y);
for(i=0;i<=x;i++)
{
for(j=0;j<=y;j++)
{
printf("\n Enter value for a[%d][%d]",i,j);
scanf("%f",&a[i][j]);
}
}
printf("\n Enter the row and column ");
scanf("%d %d",&p,&q);
for(i=0;i<=p;i++)
{
for(j=0;j<=q;j++)
{
printf("\n Enter value for b[%d][%d]",i,j);
scanf("%f",&b[i][j]);
}
}
if(y==p)
{
m=x;n=q;
}
else
{
printf("Cannot perform div... wrong dimension");
}
for(i=0;i<=m;i++)
{
for(j=0;j<=n;j++)
{
for(z=0;z<=m;z++)
{
c[i][j]=c[i][j]+(a[i][z]*b[z][j]);
}
}
}
printf("The value of m is %d and n is %d",m,n);
for(i=0;i<=m;i++)
{
for(j=0;j<=n;j++)
{
printf("\n c[%d][%d]= %f",i,j,c[i][j]);
}
printf("\n");
}
return 0;
}
Quote
