The reaction between atoms of the same element or between atoms of different elements leads to the formation of compounds. Compounds are classified as molecular or ionic based on their mode of formation.
When atoms form ions by accepting or by giving electrons, they form positive and negative ions. These ions come close together and form ionic bonds leading to the formation of ionic compounds.
The formation of a molecule of sodium chloride is an example of a compound formed by an ionic bond.
The atomic number of sodium is 11. Its electron configuration is 2, 8, 1, so it has one electron in its outermost shell. The atomic number of chlorine is 17. Its electron configuration is 2, 8, 7, so it needs one electron to complete the last shell with eight electrons to give it stability. The chlorine atom accepts one electron from the atom of sodium, leading to the formation of Na+ and Cl- ions. The positively charged sodium ion and the negatively charged chloride ion form an ionic bond due to electrostatic force of attraction resulting in the formation of a molecule of sodium chloride.
When atoms react and share pairs of electrons, they form covalent bonds thereby creating covalent or molecular compounds. A molecule of oxygen forms when two atoms of oxygen share two pairs of electrons, producing a double covalent bond. A triple covalent bond is formed between two atoms of nitrogen, creating a molecule of nitrogen.