let C(h,k)
Given:
center is on line y = x
and
tangent to the line y = 5
radius = 2
from the figure attached
k = 5-2 = 3
center of the line is y=x
or k = h
h = 3
C(3,3)
therefore, the equation of the line is,
(x-h)²+(y-k)²=r²
(x-3)²+(y-3)²=2²
for the general equation just expand the equation.