+ 1
Calculation Problem
I wrote a code and find a problem in calculation, so I want to know how C calculates it. When I calculate it by BODMASS method I got k = 3, but C shows k = 2, why? https://code.sololearn.com/c6cqUOp4e6y4/?ref=app
2 Réponses
+ 1
「HAPPY TO HELP」
j is 3 here.
I think this is happening because we're working with integers. 3/2 is calculated as 1. The part after the decimal point is ignored. If we change the line to
k = 2 * ((float) j / 2);
it should work out.
+ 1
「HAPPY TO HELP」
😊
It's the intention that matters. Your explanation was very detailed.