(a) An element X in group 2 has a valency of 2. We know that chlorine has 7 valence electrons. Therefore, the valency of chlorine Cl is 1, that is, (8 - 7).
Now, when one atom of X combines with two atoms of Cl, an ionic compound of the formula XCl2 is formed.
(b) We know that oxygen has 6 valence electrons and needs 2 more electrons to complete its octet. Therefore, the valency of oxygen O is 2, that is, (8 - 6). Both X and O have the same valency. When one atom of X combines with one atom of O, an ionic compound of the formula XO is formed.