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
Why main function is special give two reasons?
What is the equivalent code of the following statement in WHILE LOOP format?
What happens if a header file is included twice?
Is c easier than java?
What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?
What does %c mean in c?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
What is pointer to pointer in c?
Explain what is wrong with this program statement?
What is array within structure?
please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code
Do you know the use of fflush() function?
Why double pointer is used in c?
What are pointers? Why are they used?
What is the difference between malloc() and calloc() function in c language?