Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Basics Swift Operators Working With Operators

Sawyer MacDonald
Sawyer MacDonald
463 Points

What is the sign to divide?

I am doing a code challenge and forgot the operator symbol to divide. What is it?

operators.swift
// Enter your code below
let value = 200
let divisor = 5

let someOperation = 20 + 400 % 10 / 2 - 15
let anotherOperation = 52 * 27 % 200 / 2 + 5

// Task 1 - Enter your code below

value/divisor = result
let result = 40

// Task 2 - Enter your code below

1 Answer

Hi Sawyer,

The divide operator is the slash symbol /, but that isn't what you want here.

You want to assign the result of finding the number remaining after the division operation between value and divisor. That need the mod operator which is the percent sign, %. So, create a constant called result and use the mod operator between value and divisor. That looks like:

let result = value % divisor

Make sense?

Steve.