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


Please Help Members By Posting Answers For Below Questions

Why main function is special give two reasons?

953


What is the equivalent code of the following statement in WHILE LOOP format?

772


What happens if a header file is included twice?

602


Is c easier than java?

575


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

748






What does %c mean in c?

656


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

1664


What is pointer to pointer in c?

636


Explain what is wrong with this program statement?

624


What is array within structure?

589


please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code

1711


Do you know the use of fflush() function?

605


Why double pointer is used in c?

571


What are pointers? Why are they used?

632


What is the difference between malloc() and calloc() function in c language?

607