WAP to multiply two matrices of order 3×3

#include <stdio.h>
#include <stdlib.h>

int main()
{
int a[3][3],b[3][3],c[3][3],i,j,k,sum;
printf("enter the first matrix");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
 scanf("%d",&a[i][j]);                                
}}
printf("enter the second matrix");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
 scanf("%d",&b[i][j]);                                
}}
for(i=0;i<=2;i++)
{
  for(j=0;j<=2;j++)
  {
     sum=0;
     for(k=0;k<=2;k++)
     {
       sum=sum+a[i][k]*b[k][j];
     }                     
     c[i][j]=sum;
}}
//printing the multiplied matric c
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
 printf("%d",c[i][j]);                                
}
printf("\n");
}
system("pause");
return(0);
}
Advertisements

Leave a comment

Filed under TUTORIALS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s