0

Why is output wrong when i keep brackets in summing 1/i

https://code.sololearn.com/cSp0rD0goxNE/?ref=app

6th Sep 2020, 11:53 AM
Prashant Pandey
Prashant Pandey - avatar
2 ответов
0
Change to 1 to 1.0 sum+=(1. 0/i);
6th Sep 2020, 12:24 PM
Jayakrishna 🇮🇳
+ 1
Try to use a float value (1.0f) instead of 1 (it's an integer) at line 11. sum += (float)(1.0f / i);
6th Sep 2020, 12:07 PM
Ipang