Custom Search
Multiplication of Matrices
A program to find the multiplication of the given matrices
/*******************************************************
* MYCPLUS Sample Code - http://www.mycplus.com *
* *
* This code is made available as a service to our *
* visitors and is provided strictly for the *
* purpose of illustration. *
* *
* Please direct all inquiries to saqib at mycplus.com *
*******************************************************/
#include
#include
void main()
{
int mat1[2][2],mat2[2][2],mat3[2][2],i,j,k;
clrscr();
printf("************A program to find the multiplication of the given matrices***********\n\n");
printf("************Enter the value for the 1st matrix************\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("\nEnter the value for %d row,%d column:",i+1,j+1);
scanf("%d",&mat1[i][j]);
}
}
printf("\n************Enter the value for the 2nd matrix************\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("\nEnter the value for %d row,%d column:",i+1,j+1);
scanf("%d",&mat2[i][j]);
}
}
printf("\n****************************The given matrices are*****************************\n\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",mat1[i][j]);
}
printf("\n");
}
printf("\n\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",mat2[i][j]);
}
printf("\n");
}
printf("\n****************************The multiplication of the matrices is*************\n\n");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
mat3[i][j]=0;
for(k=0;k<2;k++)
{
mat3[i][j]=mat3[i][j]+(mat1[i][k]*mat2[k][j]);
}
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",mat3[i][j]);
}
printf("\n");
}
getch();
getch();
}
Tags: Arrays, C++ Programming, Source Code
Like What you See?
Become one of the regulars by subscribing! You'll be the first to know when we add more great posts just like this. Join up by either RSS Feeds or Email Updates today!
There are No Comments to this post. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response or TrackBack from your own site.


































