-1

The following is the code

    float lc = lcount/argc*100;
    return lc;

This is the debug

I tried to get 362.5 but the result is 300

An Dy Andy
  • 21
  • 5
  • What is the type of `lcount`? Please provide complete code as a [mre]. But likely it is an `int`. Which means `lcount/argc` is integer division with a result of 3. Try: `(float)lcount/argc*100` – kaylum Apr 02 '22 at 06:11

1 Answers1

0

because initially it will computer division(because at the left of equation and having same precedence as multiplication ) lcount/argc(29/8=3) and then multiplied by 100. And at the last the computed result will be stored in floating format.

Your problem might be you are thinking initially it will compute 29/8=3.625 which wouldn't.

Victor
  • 83
  • 2
  • 8