m = 100g = 0.1kg, x = 5cm = 0.05m, k = 100N/m
When the body leaves the spring, let the velocity be v,
$\frac{1}{2}\text{mv}^2=\frac{1}{2}\text{k}\text{x}^2$
$\Rightarrow\text{v}=\text{x}\sqrt{\frac{\text{k}}{\text{m}}}$
$\Rightarrow0.05\times\sqrt{\frac{100}{0.1}}=1.58\text{m}/\text{sec}$
For the projectile motion, $\theta=0^\circ,\text{Y}=-2$
Now, $\text{Y}=(\text{u}\sin\theta)\text{t}-\frac{1}{2}\text{gt}^2$
$\Rightarrow-2=\Big(\frac{-1}{2}\Big)\times9.8\times\text{t}^2$
$\Rightarrow\text{t}=0.63\text{sec}$
So, $\text{x}=(\text{u}\cos\theta)\text{t}$
$\Rightarrow1.58\times0.63=1\text{m}$