One volume of a hydrocarbon require 3 volume of oxygen for complete combustion then formula for hydrocarbon

Let's call the hydrocarbon CxHy. Then CxHy + 3O2 ==> xCO2 + (y/2)H2O

We know, by adding the O atoms, that 1/2 y(from the H2O) + 2x (from the CO2) that 2x + 1/2 y = 6.
If we assume x = 1, then y = 8 and C1H8 is not possible. Try x = 2, then you can do the algebra but y = 4 and the formula is C2H4 which is possible. Now write the equation,
C2H4 + 3O2 ==> 2CO2 + 2H2O and that works; therefore, C2H4 must be the empirical formula for the hydrocarbon.