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

What is static and volatile in c?

783


Is struct oop?

584


What is a structural principle?

643


pierrot's divisor program using c or c++ code

1734


Are the variables argc and argv are always local to main?

576






A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none

735


explain how do you use macro?

669


Explain about C function prototype?

613


Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;

613


What kind of structure is a house?

562


Explain the difference between malloc() and calloc() function?

604


What is a string?

668


Explain the advantages and disadvantages of macros.

630


What is the difference between malloc calloc and realloc in c?

651


How can I write functions that take a variable number of arguments?

631