Matrix Multiplication using C language !

 #include <stdio.h>


inp(int a[50][50],int n){

int i,j;

for(i=0;i<n;i++){

for(j=0;j< n;j++){

scanf("%d",&a[i][j]);

}

}

}

show(int b[50][50],int n){

int i,j;

for(i=0;i<n;i++){

for(j=0;j<n;j++){

printf("%d  ",b[i][j]);

}

printf("\n");

}

}

multi(int a[50][50],int b[50][50],int n){

int i,j,k,s=0;

int ab[50][50];

for(i=0;i<n;i++){

for(j=0;j<n;j++){

for(k=0;k<n;k++){

s = s + a[i][k] * b[k][j];

}

ab[i][j] = s ;

s = 0;

}

}

show(ab,n);

}

void main (){

int n;

printf("Enter the Range : \n");

scanf("%d",&n);

int A[n][n],B[n][n];

printf("Enter the Elements of A matrix : \n");

inp(A,n);

printf("Enter the Elements of B matrix : \n");

inp(B,n);

printf("Multiplication of A & B : \n");

multi(A,B,n);


}

Comments