I have a written a c program on the product of two matrices.When i compile i find no error but when i run it i find the aforementioned error.I have tried multiple solutions as suggested by youtube videos.But nothing worked.I have pirated windows 10 copy installed on my pc.I run the program on codeblocks 20.03 Here is the program:
#include<stdio.h>
int main()
{
int r1,r2,c1,c2,a[r1][c1],b[r2][c2],c[r1][c2],sum=0;
printf("Enter the rows and columns Of matrix a and b(r1,c1,r2,c2):");
scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
printf("Input matrices elements");
int i,j;
printf("Input elements of matrix a:");
for(i=0;i<r1;i++){
for(j=0;j<c1;j++)
scanf("%d",&a[i][j]);
}
printf("Input elements of matrix b:");
for(i=0;i<r2;i++){
for(j=0;j<c2;j++)
scanf("%d",b[i][j]);
}
printf("Matrix a is:\n");
for(i=0;i<r1;i++){
for(j=0;j<c1;j++)
printf("%d ",a[i][j]);
}
printf("Matrix b is:\n");
for(i=0;i<r2;i++){
for(j=0;j<c2;j++)
printf("%d ",b[i][j]);
}
if(c1==r2)
printf("\nMatrix multiplication is possible.....\n");
else
return 0;
for(i=0;i<r2;i++){
sum=0;
for(j=0;j<c2;j++)
sum+=a[i][j]*b[j][i];
c[i][j]=sum;
}
printf("\nProduct of matrices is:\n");
for(i=0;i<r1;i++){
for(j=0;j<c2;j++)
printf("%d ",c[i][j]);
printf("\n");
}
return 0;
}
Note: My program may not be correct,all i want to do is run the program and letter on i will debug it.