Type Casting in C

Level 125 keystrokes

Casts the floating-point value 3.7 (a double) to an integer, truncating it to 3.

C code

// (int) casts a value to integer type
// The fractional part is dropped toward zero (no rounding): 3.7 → 3
1printf("%d\n", (int)3.7);

Output

3
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
  • )× 2
  • ,× 1
  • ;× 1
  • .× 1
  • \× 1
  • %× 1

More C examples at level 1

← C typing practice