The relative atomic mass of C is 12 g. So, to calculate how many atoms of C there are, we will divide 30 g by 12 g:
30 g ÷ 12 g = 2.5
The relative atomic mass of H is 1 g. So, to calculate how many atoms of C there are, we will divide 5.05 g by 1 g:
5.05 g ÷ 1 g = 5.05 ≈ 5
Now, let's calculate the ratio of C and H atoms:

This means there are 2 H atoms more than C atoms and therefore,
the compound’s molecular formula is CH₂.