0

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.

Edited by ~s.o.s~: Added code tags, learn to use them.

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by zeroliken
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.