to find the program of matrix multiplication using arrays

Answer Posted / brajesh kumar dwivedi

#include<iostream.h>
#include<conio.h>
const size=10;
void main()
{
int a[size][size],b[size][size],c[size][size],n,m,i,j,k;
char v;
clrscr();
do
{
m=n=3;
cout<<"Enter a 3X3 matrix(1)\n";

for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>a[i][j];
}
}
cout<<"Enter a 3X3 matrix(2)\n";

for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>b[i][j];
}
}

for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
c[i][j]=0 ;
for(k=0;k<n;k++)
{
c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
}
}
}

cout<<"The product matrix is :"<<endl;

for(i=0;i<m;i++)
{
cout<<endl;
for(j=0;j<n;j++)
{
cout<<c[i][j]<<"\t";
}
}
cout<<"\nWanna do it again ? (y/n)";
cin>>v;
}
while(v=='y'||v=='Y');
getch();
}

Is This Answer Correct ?    39 Yes 26 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

653


What is #line in c?

564


What does main () mean in c?

616


How can I find the modification date and time of a file?

605


What happens if a header file is included twice?

601






What are the types of unary operators?

663


Difference between malloc() and calloc() function?

655


What 'lex' does?

720


What is pointers in c?

659


Is there a built-in function in C that can be used for sorting data?

745


What is the maximum no. of arguments that can be given in a command line in C.?

673


What are valid operations on pointers?

671


What is the advantage of a random access file?

640


Is it valid to address one element beyond the end of an array?

676


Which one would you prefer - a macro or a function?

605