+ 4
How to remove zeroes after decimal point in C language.
The out put is "5.000000", whereas it should be just "5".
9 Answers
+ 4
Another solution using format specifier:
printf("%.0f" , f );
+ 2
printf("%d", (int)5.000000);
Edited: add casting to int
+ 2
Oh. Yes. Mirielle
I thought it would work .. I had to check it out before.. I did it after posting.. Thank you ..
This works well also :
float f = 5.0000;
int i= f; // int i = (int) f;
printf("%d", i) ;
+ 2
Kevin â
okay Thanks đ
+ 2
Store the value in a integer variable or those cast the whole expression to integer.
+ 1
Mirielle I guess I've tried it but didn't work for my situation (solving challenge)
+ 1
Mirielle sorry dude but didn't get it đ
+ 1
Mirielle okayđ€Ł
+ 1
float example = 5.5555;
int a;
a = example;
// a = 5