New course! Every coder should learn Generative AI!
Try a free lesson0
Why is output wrong when i keep brackets in summing 1/i
2 Answers
0
Change to 1 to 1.0
sum+=(1. 0/i);
+ 1
Try to use a float value (1.0f) instead of 1 (it's an integer) at line 11.
sum += (float)(1.0f / i);