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.

it's result is correct but it return the value 0

that's because of the return 0 statement at the end of the function,
return the variable you need instead

when it removed then display the value 1186.to avid this i'm using return 0;

instead of removing it replace 0 with the variable you want to return

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.