Sugar is made of carbon, hydrogen, and oxygen atoms. When heated over a candle, these elements react with the fire to turn into a liquid. The heat causes the sugar's atoms to combine with the oxygen in the air, forming new groups of atoms. Energy is released in this chemical reaction in the form of smoke and black soot.