H2SO4 H: 1 x 2 = 2 S: 32 x 1 = 32 O: 16 x 4 = 64 98amu
H: 2/98 x 100 = 2% S: 32/98 x 100 = 33% O: 64/98 x 100 = 65%
MGNO3 (I think you meant Mg(NO3)2 aka Magnesium Nitrate. So this might be wrong because I did the version you sent instead of what I thought you might mean.)
Mg: 24 x 1 = 24 N: 14 x 1 = 14 O: 16 x 3 = 48 86amu
Mg: 24/86 x 100 = 28% N: 14/86 x 100 = 16% O: 48/86 x 100 = 56%