Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C Language Examples - Output a floating-point number

C Language Examples - Output a floating-point number

C Language Examples C Language Examples

Use printf() and %f to output a floating-point number.

Example

#include

<

stdio.h

int

main

(

)

{

float

f

;

// Declare a floating-point variable

f

=

12

.001234

;

// Define a floating-point variable

printf

(

"

The value of f is %f

"

,

f

)

;

return

0

;

}

Output result:



f 的值为 12.001234

C Language Examples C Language Examples