Hi,
I have this simple code here:
Code:
#include <iostream>
int multiply (double x, double y)
{
double result = x*y;
return (result);
}
int main()
{
double a = 2.2;
double b = 2.7;
double c = multiply(a,b);
std::cout << c;
}
And all I get as an output is 5. However, if I use this:
Code:
#include <iostream>
int main()
{
double a = 2.2;
double b = 2.7;
double c = a * b;
std::cout << c;
}
I get the answer 5.94 (which is what I'm looking for).
I can't work out why the first example is not outputting a decimal number. I have set the variables as a double so I just can't see why this is not working for me.
Any help is more than appreciated. I would prefer a hint rather than a straight answer just to set me in the right direction. Thanks.