Float Output in C

Level 126 keystrokes

Outputs a floating-point number with 2 decimal places using %.2f format.

C code

// %f is the format specifier for floating-point numbers
// .2 rounds to 2 digits after the decimal point: 3.14159 → 3.14
1printf("%.2f\n", 3.14159);

Output

3.14
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this C code and how often they appear.

  • .× 2
  • "× 2
  • ,× 1
  • ;× 1
  • (× 1
  • )× 1
  • \× 1
  • %× 1

More C examples at level 1

← C typing practice