+ 2
Why this code does not execute properly?
int multiply(int a, int b){a * b;} I found these code at codewars.com and try to solve it several times but keep failing.
5 odpowiedzi
+ 15
you have to return a * b;
so:
int multiply(int a, int b) { return a * b; }
+ 1
oh.. thats it? :'v .. lul i try everything i knew but not this one.. thanks.. btw why i have to return a*b ?
+ 1
when you return a*b, the product of both numbers will recieved by the main function.
For eg:
cout<<multiply(4,5);
The values will be pass to the function n the function will return the product (i.e., 20), which will be printed on screen as output.
+ 1
you didn't have written the return keyword
it should be like
int multiply (int a, int b)
{
return a*b; }