Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to get accurate numbers with decimal points by division in C language?
How to get accurate numbers with decimal points by division in C language?
5/2 is an integer division and the result is an integer.

If you change the divisor or dividend to floating-point type and then control the output, for example: printf("%0. 1f ",x); The result is 2.5.

The result will contain decimals!

# include & ltstdio.h & gt

void main()

{

Floating point a = 5.0

int b = 2;

printf("%0. 1f ",a/b);

}