We know, the distance between (x1,y1) and (x2,y2)
is √(x2−x1)2+(y2−y1)2
Here, the distance = 5 units, x1=5, x2=1, y1=−2 and y2=a
Therefore, 5 =√(1−5)2+(a+2)2
⟹ 25=16+(2+a)2
⟹ (2+a)2=25−16
⟹ (2+a)2=9
Taking square root, 2 + a = ±3
⟹ a = -2 ± 3
⟹ a = 1, -5