Answer: The chemical formula for the ionic compound formed will be

Step-by-step explanation:
Magnesium is the 12th element of the periodic table having electronic configuration of
![[Ne]3s^(2)](https://img.qammunity.org/2019/formulas/chemistry/middle-school/nu9shj3d57i0rl8sm20dlitg7yftke8yy5.png)
This element will loose 2 electrons and thus shows an oxidation state of +2 units.
Oxygen is the 8th element of the periodic table having electronic configuration of
![[He]2s^22p^4](https://img.qammunity.org/2019/formulas/chemistry/middle-school/c1zczz8bka52w2kzlh8huf1xivxcwneuyd.png)
This element requires 2 electrons and thus shows an oxidation state of -2 units.
By criss-cross method, the oxidation state of the ions gets exchanged and hence, they form the subscripts of the opposite ion. This results in the formation of a neutral compound.
Thus, the chemical formula for the ionic compound will be
