0% found this document useful (0 votes)
36 views

Multiplication of Matrix

This C++ code defines a function to multiply two 3x3 matrices and print the result. It takes in the two input matrices, multiplies them using nested for loops, stores the result in a third matrix and prints it out. The main function calls this multiplication function after inputting the two matrices, displaying the inputs, and passing them to be multiplied.

Uploaded by

Swapnil Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Multiplication of Matrix

This C++ code defines a function to multiply two 3x3 matrices and print the result. It takes in the two input matrices, multiplies them using nested for loops, stores the result in a third matrix and prints it out. The main function calls this multiplication function after inputting the two matrices, displaying the inputs, and passing them to be multiplied.

Uploaded by

Swapnil Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Q 13. WAP to multiply two matrix and print the result .

#include<iostream.h>
#include<conio.h>
void mult(int a[][3],int b[][3],int c[][3])
{
int i,j,k;
cout<<"After multiplication matrix is :\n";
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];
}
cout<<c[i][j]<<" ";
}
cout<<endl;
}
}
void main()
{
clrscr();
int a[3][3],b[3][3],c[3][3],i,j,k;
cout<<"Enter First Matrix : \n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>a[i][j];
}
}
cout<<"Enter Second Matrix : \n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cin>>b[i][j];
}
}
cout<<"First matrix is :\n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
}
cout<<"Second matrix is : \n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<b[i][j]<<" ";
}
cout<<endl;
}
mult(a,b,c);
getch();
}

You might also like