The correct answer is (b) 26 years.
Three years ago, the sum of the ages of X and Y was $2 \times 18 = 36$ years.
Now, the sum of their ages is $36 + 2 \times 3 = 42$ years.
The sum of the ages of X, Y, and Z is $42 + 22 = 64$ years.
The age of Z is $64 – 42 = 22$ years.
Option (a) is incorrect because 30 years is the sum of the ages of X and Y three years ago, not their current ages.
Option (c) is incorrect because 29 years is the sum of the ages of X, Y, and Z three years ago, not their current ages.
Option (d) is incorrect because 29.5 years is not an integer.