Find Matrix Multiplication using recursion in C Tamil


#include<stdio.h>
#include<conio.h>
void mul(int [][3],int [][3],int [][3],int,int,int,int);
void dis(int [][3],int);
void main()
{
	int a[3][3],b[3][3],c[3][3],n,i,j,k;
	clrscr();
	printf("\nenter limit :");
	scanf("%d",&n);
	printf("\nEnter matrix: A :");
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	printf("\nEnter matrix: B :");
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			scanf("%d",&b[i][j]);
		}
	}
	mul(a,b,c,n,0,0,0);
	printf("\nResult Matrix:\n");
	dis(c,n);
	getch();
}
void mul(int a[3][3],int b[3][3],int c[3][3],int n,int i,int j,int k)
{
      if(i<n)
      {
	   if(j<n)
	   {
	       if(k==0)
	       {
			c[i][j]=0;
	       }
		if(k<n)
		{
			c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
			k++;
			mul(a,b,c,n,i,j,k);
		}
		k=0;
		j++;
		mul(a,b,c,n,i,j,k);
	   }
	   j=0;
	   i++;
	   mul(a,b,c,n,i,j,k);
      }
}
void dis(int c[3][3],int n)
{
	int i,j;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
		       printf("\t%d",c[i][j]);
		}
		printf("\n\n");
	}
}

Login To Download Source Code

Leave a Comment:

Login To Comment

List Of Programs


Goto Examples

Operators

Looping

Number Conversion

Pattern Design

Arrays

Matrix Examples

Sorting Examples

String Function

Change Case

String In C

Maths Functions

User Defined Functions

Recursive Functions

Pointer

Structure

File Concept

Calender Programming