+ 1

[SOLVED]What is wrong ?

guys , can someone please tell me why is this program outputs average always on the form X.0000 ? for example it should output 5.2351 but it outputs 5.00000 ? I cannot figure out the reason. https://code.sololearn.com/cSslM42p8A2I/?ref=app

10th Dec 2020, 12:51 AM
Abderrahim Rhitrif
Abderrahim Rhitrif - avatar
3 Respostas
+ 2
integer division is implicitly converted to float. try average = (float)(j-count)/count; //line 18 don't use gets(); use fgets();
10th Dec 2020, 1:05 AM
Flash
+ 1
try casting the "count" to float for your calculations.
10th Dec 2020, 1:04 AM
rodwynnejones
rodwynnejones - avatar
+ 1
Flash thanks man
10th Dec 2020, 1:07 AM
Abderrahim Rhitrif
Abderrahim Rhitrif - avatar