Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int a[100][100],b[100][100],c[100][100],ax,ay,bx,by,i,j,k;
- printf("A Col: ");
- scanf("%d",&ax);
- printf("A Row: ");
- scanf("%d",&ay);
- printf("B Col: ");
- scanf("%d",&bx);
- printf("B Row: ");
- scanf("%d",&by);
- if(ay==bx) {
- printf("Enter Matrix A:\n");
- for(i=0; i<ay; i++) for(j=0; j<ax; j++) scanf("%d",&a[i][j]);
- printf("Enter Matrix B:\n");
- for(i=0; i<by; i++) for(j=0; j<bx; j++) scanf("%d",&b[i][j]);
- for(i=0; i<ay; i++) {
- for(j=0; j<bx; j++) {
- c[i][j]=0;
- for(k=0; k<ax; k++) {
- c[i][j]+=a[i][k]*b[k][j];
- }
- }
- }
- for(i=0; i<ay; i++) {
- for(j=0; j<bx; j++) {
- printf("%d\t",c[i][j]);
- }
- printf("\n");
- }
- } else {
- printf("Can't multiply between matrix A and B\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment