Web viewed 3k times.
How to get only one zero after decimal in c. Web this is remove the extra zeros after the decimal. // to input a data in the variable a scanf (%f,&a); Anyway, you need to include the library, like this.
Web i have a float number for example 12.12123 is there a function which would display only number with 2 digits after decimal point 12.12 ? Web to get rid of the trailing zeros, you should use the %g format: Web this changes the type of the decimal and you need to convert back to decimal again if you want to have a decimal.
Actually, i'm surprised that anyone mentioned printf! Web i think you are very new to c programming. You just have to use a decimal literal:
This is a very simple job. Private static double calculateslabtax (int nslabstarttaxable, int nslabendtaxable, float. After the question was clarified a bit, that.
For example, below program sets the precision for 4 digits after the decimal point: You can't get the int part of a decimal because the decimal is too friggen big to put in the int box. Integer display %d print as decimal integer %6d print as decimal integer, at least 6 characters wide %f print as floating point %6f print as.
That will remove all trailing zeros from your. I have tried following code : Web the easiest way to do this, is using cstdio's printf.