Table is sold at price(selling price) higher than the price for which it is bought(cost price).So,this is a profit and we need to calculate gain percentage.
Selling price=500
Cost price=400
Profit=Selling price-cost price
=500-400=100
Now to calculate gain percentage, it's nothing but how much percentage of cost price is the gain.So,
%gain=(gain/cost price)*100
=(100/400)*100=25%