Let the number of C atoms in the hydrocarbon be n.
CnH2n+2+3n+12O2→nCO2+(n+1)H2O
Volume is directly proprtional to the number of moles of gas.
First contraction in volume is due to water.
Hence, n+1=2.5
n=1.5≃2
Second contraction is due to carbon dioxide gas.
Hence, n=2