This question was answered here: Sturm-Liouville eigen value problem with one-dimensional eigenspace
The following is a rephrasing of the answer given there, without the operator-theoretic context which is given there.
Consider the ODE $$(py')' + qy = \lambda y.$$ Then, there exit unique solutions $\varphi_\lambda$ and $\psi_\lambda$ of this ODE with $$\varphi_\lambda(0)=0, \ p\varphi'_\lambda(0)=1; \ \psi_\lambda(0)=1, \ p\psi'_\lambda(0)=0.$$
Then, $\varphi_\lambda, \psi_ \lambda$ span the solution space of the ODE and every solution can be written in a unique linear combination of these two solutions: $y=A\varphi_\lambda + B\psi_\lambda$.
If there is some nontrivial $y$ which solves the ODE with $y(0)=y(1)=0$, then by $y(0)=A\cdot 0 + B \cdot 1$ we have $B=0$ and $y$ is a multiple of $\varphi_\lambda$ (furthermore, $\varphi_\lambda(1)=0$). Thus $y_1=A_1 \varphi_\lambda $ and $y_2=A_2\varphi_\lambda$ for some nonzero $A_1,A_2$ and we have found $c=\frac{A_2}{A_1}$.