0Pricing
Swift Academy · Lesson

Arithmetic and Compound Assignment Operators

Use +, -, *, /, % and compound forms safely.

Arithmetic Operators

Swift provides the four standard arithmetic operators for all number types: + (addition), - (subtraction), * (multiplication), and / (division). They work on Int, Double, and Float.

let sum = 7 + 3
let diff = 10 - 4
let product = 6 * 5
print(sum, diff, product)

Addition and Subtraction

Addition and subtraction behave exactly as in math. The result type matches the operand types: two Int values produce an Int.

let apples = 5
let eaten = 2
let remaining = apples - eaten
print("Remaining apples:", remaining)

All lessons in this course

  1. Arithmetic and Compound Assignment Operators
  2. Comparison and Identity Operators
  3. Logical Operators and Short-Circuiting
  4. Bitwise and Overflow Operators
← Back to Swift Academy