What Happens When Sugar is Heated?

Sugar’s composition is C12 H22 O11. When it’s heated, it begins to melt, and it changes it’s composition while water and oxygen escape, then it becomes pure carbon. That’s why it turns black.