Untitled
unknown
plain_text
2 years ago
1.1 kB
6
Indexable
#include<stdio.h>
int main(){
int a[50][50],b[50][50],c[50][50],r1,c1,r2,c2,i,j;
printf("Enter the size of mat");
scanf("%d%d",&r1,&c1);
printf("Enter the size of mat");
scanf("%d%d",&r2,&c2);
if(r1==c1&&r2==c2){
printf("elements1\n");
for(i=0;i<r1;i++){
for(j=0;j<c1;j++){
scanf("%d",&a[i][j]);
}
}
printf("matrix is\n");
for(i=0;i<r1;i++){
for(j=0;j<c1;j++){
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("elements2\n");
for(i=0;i<r2;i++){
for(j=0;j<c2;j++){
scanf("%d",&b[i][j]);
}
}
printf("matrix is\n");
for(i=0;i<r2;i++){
for(j=0;j<c2;j++){
printf("%d\t",b[i][j]);
}
printf("\n");
}
for(i=0;i<r1;i++){
for(j=0;j<c1;j++){
c[i][j]=0;
for( int k=0;k<c1;k++){
c[i][j]+=a[i][k]*b[k][j];
}
}
}
printf("resultant\n");
for(i=0;i<r1;i++){
for(j=0;j<c1;j++){
printf("%d\t",c[i][j]);
}
printf("\n");}
}
else{
printf("Invalid");
}
return 0;
}
Editor is loading...
Leave a Comment