- 1
How to print 12.235 if the input taken is 12.2345 in the c-language. Please help me with this
3 Antworten
+ 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);
0
Jayakrishna🇮🇳 it will print 12.234 not required output i.e 12.235
I tried that already
- 2
printf("%.3f",12.2345); //dot3 in between.