Step-by-step explanation:
It is known that the atomic number of magnesium is 12 and its electronic distribution is 2, 8, 2. And, in order to attain stability a magnesium atom will tend to lose its valence electrons.
That is, being a metal magnesium atom will lose its 2 valence electrons and hence it forms a
ion.
Equation for this type of loss is as follows.

Therefore, we can conclude that the charge of the ion formed by the
atom is +2.