To declare a variable, you use the var keyword:
let radius = 3.45 var myAge = 25//from w w w .j a va2 s. c om var circumference = 2 * 3.14 * radius print(radius) print(myAge) print(circumference)
Once a variable is created, you can change its value:
let diameter = 20.5 var radius = 10.1 var circumference = 2 * 3.14 * radius circumference = 2 * 3.14 * diameter/2// ww w. j ava2s . com print(circumference)
In the following example, you explicitly use the String() initializer to convert the value of myAge to a string value before concatenating it with another string:
var myAge = 25 var strMyAge = "My age is " + String(myAge) print(strMyAge)