First we need to write the balanced equation for the reaction. In this case it is Mg + 2HCl -> MgCl2 + H2. Now we need to work out the maximum theoretical yield of MgCl2 from 12g of Mg. 12g of Mg is 0.5 moles, so a maximum of 0.5 moles of MgCl2 can be created because the reaction ratio is 1:1 as our equation shows. 0.5 moles of MgCl2 weighs 47.5g. Finally we can use the equation % yield = (actual yield / theoretical yield) x 100. In this example, (20 / 47.5) x 100 = 42.1%.