Chemistry: Sugar Molecules

A sugar molecule has twice
as many atoms of hydrogen as it does oxygen and one more
atom of carbon than oxygen. If a sugar molecule has a
total of 45 atoms, how many are oxygen? How many are
hydrogen?

$H$ = number of hydrogen atoms
$O$ = number of oxygen atoms
$C$ = number of carbon atoms
 

twice as many atoms of hydrogen as it does oxygen
$H = 2O$

$H - 2O + 0C = 0$   ←   Eq. (1)
 

one more atom of carbon than oxygen
$C - 1 = O$

$0H - O + C = 1$   ←   Eq. (2)
 

total of 45 atoms
$H + O + C = 45$   ←   Eq. (3)
 

From Equations (1), (2) and (3)
$H = 22 ~ \text{ atoms}$
 

You may find this link useful: https://www.exploratorium.edu/cooking/candy/sugar.html