Complete the code to create a struct named Point.
struct [1] {
var x: Int
var y: Int
}The keyword struct defines a value type named Point.
Complete the code to assign one struct instance to another.
var p1 = Point(x: 5, y: 10) var p2 = [1]
Assigning p1 to p2 copies the value because structs are value types.
Fix the error in copying and modifying a struct instance.
var p1 = Point(x: 3, y: 4) var p2 = p1 p2.[1] = 10
The struct Point has properties x and y. Modifying x on the copy is valid.
Fill both blanks to create a copy of a struct and change its property.
var original = Point(x: 1, y: 2) var copy = [1] copy.[2] = 5
Assigning original to copy creates a value copy. Then modifying x changes only the copy.
Fill all three blanks to demonstrate that modifying a copy does not affect the original struct.
var a = Point(x: 7, y: 8) var b = [1] b.[2] = 0 print(a.[3])
Copy a into b. Change b.x. Printing a.y shows the original value unchanged.
