-4

Hi i was trying to create a function that printed out the statement f(variable)degrees Fahrenheit = c(variable) degrees Celsius in swift and I am having issues printing it mainly cause its a variable with numbers and im trying to put it into a string I tried some different types of decleratino but it hasnt worked. and sorry for repetitive questions

var f = 68.0;
var c = (f - 32.0) * 5.0 / 9.0;
var conversion = "f degrees Fahrenheit = c degrees Celsius"

print(conversion)
Shivam Parmar
  • 1,520
  • 11
  • 27

1 Answers1

1

You need to use String interpolation, otherwise it's just text.

Replace c with \(c) to actually get the value of variable c value. Also f with \(f) for the same reason.

var conversion = "\(f) degrees Fahrenheit = \(c) degrees Celsius"

Gustavo Vollbrecht
  • 3,188
  • 2
  • 19
  • 37