Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to convert real numbers into integers after rounding decimal points in C language?
How to convert real numbers into integers after rounding decimal points in C language?
You can also do this:

# include & ltstdio.h & gt

Master ()

{

Floating I;

Printf ("Please enter a number i:");

scanf("%f ",& ampI); /* You enter a numerical value and assign it to I */

printf("%.0f ",I); /* %m.nf means that the data specified for output occupies m columns, including n decimal places. If the numerical length is less than m, the left end is filled; If it is greater than m, it will be output according to the original number. So if we set n to 0, that is, the number of decimal places is 0, then the decimal part will be rounded off automatically, and then the integer will be output. Note that this method probably cannot use */

}