Dear student,
Magnesium burns on air to form magnesium oxide.
2Mg (s) + O2 (g) [from air] ------------> 2MgO (magnesium oxide)
copper sulfate when heated in dry tube loses water of hydration and itself becomes anhydrous.
CuSO4.5H2O (s) ---------------------> CuSO4 (s) + 5H2O
Copper sulfate (blue in color) Copper sulfate anhydrous (white in color)
Regards