You've been given the composition in percent which we can write as grams and then divide by the mass of the element.
#CrArr(84.21cancel(g) cancel (C))/(12 cancel(g) cancel( C))= 7.0175 mol#
#HrArr(15.79 cancel(g)cancel(C))/(1 cancel(g) cancel (C))=15.79 mol#
Now divide each by the smallest mole. i.e: #7.0175#
#CrArr(7.0175cancel (mol))/(7.0175cancel (mol))=1.0#
#HrArr(15.79cancel(mol))/(7.0175cancel(mol))=2.25#
You realize that 2.3 is not a whole number as compared to 1.0. So now we multiply by a number that will give us a whole number for H.
If you multiply by #1,2, or 3#, you still don't get a whole number until you multiply by 4.
Rememember whatever you do to H, you do same to C.
#CrArr1.0*4=4#
#HrArr2.25*4=9#
#:.# The empirical formula is #C_4H_9#
Molecular formula is found by:
#n#(empirical formula)
#n=# (molecular weight)/(molar mass)
Molar mass of #C_4H_9= (12*4) +(1*9)=57(g)/(mol)#
#n=(114 cancel(g)/cancel(mol))/(57 cancel(g)/cancel(mol))=2#
#n(C_4H_9)=2(C_4H_9)#
#:.# the molecular formula is #C_8H_18#