Integer Arithmetic in Swift

Level 117 keystrokes

Shows operator precedence: * is evaluated before +, so 10 + 5 * 2 prints 20.

Swift code

// 5 * 2 = 10 is computed first, then 10 + 10 = 20
1print(10 + 5 * 2)

Output

20
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 Swift code and how often they appear.

  • (× 1
  • )× 1
  • *× 1
  • +× 1

More Swift examples at level 1

← Swift typing practice