Take any compound, for example Al2O3.
For determining %composition of an element in the compound, divide total mass of the element with total mass of the compound and then multiply it by 100.
In the case of Al2O3, if we have to find the % composition of oxygen then,
R.M.M. of Al2O3 = 2×27 + 3×16
= 54 + 48
= 102
Percent composition of oxygen
= (G.M.M. of oxygen/R.M.M. of
Al2O3) × 100
= (48/102) × 100
=47.06%