How to print 12.235 if the input taken is 12.2345 in the c-language. Please help me with this | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
- 1

How to print 12.235 if the input taken is 12.2345 in the c-language. Please help me with this

18th Aug 2020, 4:47 PM
Mayank Pathak
Mayank Pathak - avatar
3 Respuestas
+ 1
Mayank Pathak oh.. You need rounding..? It also possible with same.. But you cant get that automatically.. <0.5 will rounded to 0.0 and >0.5 will.e rounded to 1.0 In your case, 12.2345 for 3 decimal places rounded to 12.234 only.. To get 12.235 write your own function Or add 0.0005 directly.. printf("%.3f" , 12.2345 +0.0005);
20th Aug 2020, 10:52 AM
Jayakrishna 🇮🇳
0
Jayakrishna🇮🇳 it will print 12.234 not required output i.e 12.235 I tried that already
19th Aug 2020, 11:00 AM
Mayank Pathak
Mayank Pathak - avatar
- 2
printf("%.3f",12.2345); //dot3 in between.
18th Aug 2020, 5:06 PM
Jayakrishna 🇮🇳