It's intersting, I believe, to consider also this other method for solving any linear equation in sine and cosine (provided that the argument is the same for both functions). Recall that cosine and sine are abscissa and ordinate of points on the circumference of radius $1$ and center in the origin of the axes.
Solving your first equation, therefore, is equivalent to finding the interection points between straight line
$$r: Y-\sqrt 3 X = 1 $$
and the circumference
$$\gamma: X^2+Y^2 = 1.$$
This brings you the system
$$
\begin{cases}
Y-\sqrt 3 X = 1\\
X^2+Y^2 = 1.
\end{cases}
$$
Replacing $Y = \sqrt 3 X + 1$ in the second equation gives you the quadratic equation
$$2X^2 +\sqrt 3 X =0,$$
and, from here, to the solutions $$(X_1 = 0, Y_1 = 1)$$ and $$\left(X_2 = -\frac{\sqrt 3}{2}, Y_2 = -\frac{1}{2}\right),$$ with a straightforward trigonometric interpretation.
I leave you as an exercise to apply the same approach to the equation you propose
$$\cos x -\sqrt 3 \sin x = 0.$$