Atoms of element X (with 2 electrons in the outer shell). combine with atoms of…