Multiplication of Matrix

                                   
                                            Multiplication of Matrix



C program to multiplication of matrix :- 

#include <stdio.h>
#include <conio.h>

void main()
{
	int a[3][3],b[3][3],c[3][3],i,j,k;
	clrscr();
	printf("\n\t Enter First Matrix : ");
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	printf("\n\t Enter Second Matrix : ");
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			scanf("%d",&b[i][j]);
		}
	}
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			c[i][j]=0;
			for(k=0;k<3;k++)
			{
			c[i][j]=c[i][j]+a[i][k]*b[k][j];
			}
		}
	}
	printf("\n\t Matrix Multiplication is : \n\n");
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			printf("\t %d",c[i][j]);
		}
		printf("\n");
	}
	getch();
}

Ouput:- 

Enter First Matrix : 1 2 1
	3 2 1
	1 2 1
	
	Enter Second Matrix : 3 3 3
	1 2 1
	1 1 1
	
	Matrix Multiplication is :
	
	6	8	6
	12	14	12
	6	8	6

Comments

Popular posts from this blog