Lukej2680 Tech Blog

Checkpoint 1

This post covers checkpoint 1 from 100 Days of Swift - Introduction to Swift module

Description
Your goal is to write a Swift playground that:

Creates a constant holding any temperature in Celsius. Converts it to Fahrenheit by multiplying by 9, dividing by 5, then adding 32. Prints the result for the user, showing both the Celsius and Fahrenheit values.

Code

let cTemp = 32

var fTemp = ((cTemp * 9) / 5) + 32

print("C value is \(cTemp)\nF value is \(fTemp)")

Explanation
Here we use let in order to make the celsius variable a constant.
After this I create the fTemp variable using the var keyword creating a changeable variable.
Finally I print the two values.

This project was taken from the HackingWithSwift website. However all code is original work by site owner.