Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - In a C language program, if I want to output decimals, what should I do? Please give me an example.
In a C language program, if I want to output decimals, what should I do? Please give me an example.

Use float or double to define a decimal and then printf(“%f or %lf”,); output. For example:

#include

void main()

{

float a=3.14;

double b=3.1415926;

printf(“%f %lf”,a,b); //Note that those defined with float use %f for output, and those defined with double use %lf output.

}

It’s more troublesome to answer on a mobile phone! If you still don’t understand anything, please contact me tonight! Hope this helps you