Well, from the information given, you are told that 10cm3 of hydrocarbon was burnt.
10CxHy + some O2 → some CO2 + some H2O
You are told that the volume contracts by 30cm3
Note water turns into a liquid when burnt as it condenses when it climatises.
This means that 10cm3 + Some O2 - Some CO2 = 30cm3
You know you have 10cm3 of the hydrocarbon so:
Some O2 - Some CO2 = 20cm3
Hold on here! Volume further contracted by 30cm3 when Sodium Hydroxide reacted
This means that
Some O2 - 20cm3 = 30cm3 → Some O2 = 60cm3
You know have an equation.
10CxHy + 50 O2 → 30 CO2 + some H2O
Divide by 10 gives CxHy + 5O2 → 3CO2 + some H2O
You have 12 oxygens on one side and you know that 6 oxygens are used on the right hand side for 3CO2 so 4 oxygens are left for the H2O.
This gives 4H2O.
CxHy + 5O2 → 3CO2 + 4H2O
Having 3 carbons on the left side gives x = 3. You have 8 hydrogen atoms on the right hand side, so y = 8.
Final Formula C3H8