moles C = mass / molar mass = 24 g / 12 g/mol = 2 mol
moles H = 4 g = 1 g/mol = 4 mol
moles O = 32g / 16.00 g/mol = 2 mol
ratio moles C : H : O
= 2 : 4 : 2
divide each number in the ratio by the lowest number
= 2/2 : 4/2 : 2/2
= 1 : 2 : 1
The empirical formula would be
CH2O