to find the program of matrix multiplication using arrays
Answer Posted / annapurna gautam
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[2][2],b[2][2],c[2][2],i,j;
cout<<"ENTER THE ELEMENT OF FIRST MATRIX"<<"\n";
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
cin>>a[i][j];
}
}
cout<<" THE FIRST MATRIX IS :"<<"\n";
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<"\n";
}
cout<<"ENTER THE ELEMENT OF SECOND MATRIX IS "<<"\n";
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
cin>>b[i][j];
}
}
cout<<"THE SECOND MATRIX IS:"<<"\n";
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
cout<<b[i][j]<<"\t";
}
cout<<"\n";
}
cout<<"THE MATRIX IS:"<<"\n";
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
c[i][j]=0;
for(int k=1;k<=2;k++)
{
c[i][j]=c[i][j]+(a[i][k] * b[k][j]);
}
}
}
cout<<"THE MULTIPLICATION OF THE MATRIX IS:"<<"\n";
for(i=1;i<=2;i++)
{
cout<<"\n";
for(j=1;j<=2;j++)
{
cout<<c[i][j]<<"\t";
}
cout<<"\n";
}
getch();
| Is This Answer Correct ? | 13 Yes | 7 No |
Post New Answer View All Answers
What are the different file extensions involved when programming in C?
What is calloc malloc realloc in c?
how can f be used for both float and double arguments in printf? Are not they different types?
What is the use of pointers in C?
the question is that what you have been doing all these periods (one year gap)
Is fortran still used in 2018?
find the sum of two matrices and WAP for it.
What are the loops in c?
What is main function in c?
What is the difference between scanf and fscanf?
What is structure data type in c?
What is a #include preprocessor?
what is the difference between 123 and 0123 in c?
What is #include stdio h?
What is quick sort in c?