multiply two numbers in swift

To multiply two numbers in Swift, you can use the * operator. Here's an example:

main.swift
let x = 5
let y = 7
let z = x * y
print(z) // Output: 35
57 chars
5 lines

In this example, we first declared two variables x and y and assigned them the values 5 and 7. We then multiplied these two numbers using the * operator and stored the result in a new variable z. Finally, we printed the value of z using the print() function, which outputs 35.

related categories

gistlibby LogSnag