matrix multiplication recursive algorithm
multiplication using recursion in c
recursive matrix multiplication java same logic
matrix multiplication using divide and conquer in c
using recursion in c find the largest element in an array
strassen's matrix multiplication program in c using divide and conquer
matrix addition using recursion
strassen matrix multiplication code in c
#include<stdio.h>
#define MAX 10
void multiplyMatrix(int [MAX][MAX],int [MAX][MAX]);
int m,n,o,p;
int c[MAX][MAX];
void main(){
int a[MAX][MAX],b[MAX][MAX],i,j,k;
printf("Enter the row and column of first matrix: ");
scanf("%d %d",&m,&n);
printf("Enter the row and column of second matrix: ");
scanf("%d %d",&o,&p);
if(n!=o){
printf("Matrix multiplication is not possible");
printf("\nColumn of first matrix must be same as row of second matrix");
}
else{
printf("Enter the First matrix: ");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
printf("Enter the Second matrix: ");
for(i=0;i<o;i++)
for(j=0;j<p;j++)
scanf("%d",&b[i][j]);
printf("\nyour First matrix is: \n");
for(i=0;i<m;i++){
printf("\n");
for(j=0;j<n;j++){
printf("%d\t",a[i][j]);
}
}
printf("\nyour Second matrix is: \n");
for(i=0;i<o;i++){
printf("\n");
for(j=0;j<p;j++){
printf("%d\t",b[i][j]);
}
}
multiplyMatrix(a,b);
}
printf("\n multiplication of two matrix is: \n");
for(i=0;i<m;i++){
printf("\n");
for(j=0;j<p;j++){
printf("%d\t",c[i][j]);
}
}
}
void multiplyMatrix(int a[MAX][MAX],int b[MAX][MAX]){
static int sum,i=0,j=0,k=0;
if(i<m){ //row of first matrix
if(j<p){ //column of second matrix
if(k<n){
sum=sum+a[i][k]*b[k][j];
k++;
multiplyMatrix(a,b);
}
c[i][j]=sum;
sum=0;
k=0;
j++;
multiplyMatrix(a,b);
}
j=0;
i++;
multiplyMatrix(a,b);
}
}