two dimensional array function

i'm new in C++ programming
1 problem comes in fuction .it's result is correct but it return the value 0 also,if i'm not use return 0; in functionin it print any value plz check this .and correct.thanx
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
int mul1(int x[][3],int y[][3])
{
int i,j,k,sum,z[3][3];
for(i=0;i< 3;i++)
{
for(j=0;j< 3;j++)
{
for(sum=0,k=0;k< 3;k++)
sum=sum+x[i][k]*y[k][j];
z[i][j]=sum;
cout<<setw(3)<<z[i][j];
}
cout<<endl;
}
return 0;
}
//end of function
int main()
{
clrscr();
int f,i,j,a[3][3],b[3][3],c[3][3],sum,k;
for(i=0;i< 3;i++)
{

for(j=0;j< 3;j++)
{
cout<<"Enter the Values of A Matrix";
cin>>a[i][j];
}
}
for(i=0;i< 3;i++)
{
for(j=0;j< 3;j++)
cout<<setw(2)<<a[i][j];
cout<<endl;
}

for(i=0;i< 3;i++)
{

for(j=0;j< 3;j++)
{
cout<<"Enter the Values of B Matrix";
cin>>b[i][j];
}
}
for(i=0;i< 3;i++)
{
for(j=0;j< 3;j++)
cout<<setw(2)<<b[i][j];
cout<<endl;
}
cout<<mul1(a,b);
getch();

i've checked with void data type .plz corret it.i'm using Turbo C++ Version 3.0 compiler.
Last edited on
please use code tags. And BTW, you are multiplying two matrices and then outputting an integer? why so? I would have done it in a different way. I'd pass two matrices and one o/p matrix. so that the function would compute the product and store it in output matrix. And then I would simply print the results.
Topic archived. No new replies allowed.