Step 1: Solve the differential equation.
Given the equation \( \cos \left( \frac{dy}{dx} \right) = a \), we integrate both sides to get:
\[
\frac{dy}{dx} = \cos^{-1} (a)
\]
Now, integrating with respect to \( x \), we get:
\[
y = \frac{y - 2}{x} + C
\]
Step 2: Apply the initial condition.
Substituting \( y(0) = 2 \) gives the constant \( C \). The solution is \( \cos \left( \frac{y - 2}{x} \right) = a \).
Step 3: Conclusion.
The correct answer is (C) \( \cos \left( \frac{y - 2}{x} \right) = a \).