The percentage profit $X$ is defined by
$$X = \left(\frac{\textrm{Amount of money you have at the end}}{\textrm{Amount of money you had at the start}} - 1\right) \times 100$$
Since you have $S$ at the end and $C$ at the start (because that's the money you needed to buy the item) then
$$X = \left( \frac{S}{C} - 1\right)\times 100 = \left(\frac{S-C}{C}\right)\times 100 = \frac{P}{C} \times 100$$
* * *
To see why your second decision has to be wrong, consider the case where you buy something for \$1 and sell it for \$1,001, so that $P$=1000. With your first definition,
$$X = 100\times \frac{1000}{1} = 100,000\%$$
which makes sense - you clearly made a huge profit, so you expect your percentage profit to be huge. With your second definition,
$$X = 100\times \frac{1000}{1001} = 99.9\%$$
which is nowhere near big enough.