How can i do this without getting an error?

You can get the result first.

let length = 8
let width = 6
let height = 4

let total = length * width * height

print("the Volume of teh box = \(total) cubic inches")

This will print " the volume of teh box = 192 cubic inches"

Blessings,
—Mark

you can also convert the result into a string,

print(“the Volume of the box = " + String(length * width * height) +” cubic inches")

1 Like

Oh good call Francis! So much more elegant!!

Blessings,
—Mark

Just use string interpolation. No need to calculate beforehand unless you’ll need that value later.

print("The volume of the box = \(length * width * height) cubic inches")
1 Like