to find the program of matrix multiplication using arrays

Answer Posted / rohit v.kamlakar

/* Program for matrix multiplication using 2D array
9/20/08
By:-
rohit.born2code@gamil.com or
rohit_kamlakar@rediff.com

*/

#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 ?    62 Yes 33 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

if (i = 0)printf ("True"); elseprintf("False"); Under what conditions will the above print out the string "True" a) Never b) Always c) When the value of i is 0 d) all of the above

713


What are dangling pointers? How are dangling pointers different from memory leaks?

621


can any one tel me wt is the question pattern for NIC exam

1558


What is the difference between abs() and fabs() functions?

605


What is optimization in c?

568






What is null pointer in c?

593


In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping

974


Do array subscripts always start with zero?

782


What is a pointer in c plus plus?

696


What is double pointer in c?

588


Who developed c language and when?

584


Explain can the sizeof operator be used to tell the size of an array passed to a function?

597


Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?

667


What is volatile variable how do you declare it?

566


What is a pointer and how it is initialized?

609