need c++ code for halvnumber() which recieves an int passed into it, divided by 2 which can be a double.
Can anyone help me?
1 2 3 4
|
double halvnumber(int i)
{
return (i/2);
}
|
Last edited on
why it will not work?
is there any reason?
But visual c++ compiler return double without ".0", anyway, thanks for that information
That is because the result of the integer division is ‘cast’ to double to be returned.
What would be the result of ‘halvnumber(1)’?
yeah, you are right;)
without ".0" it returns 0.000, with it, it returns 0.500