I. Formation of sodium chloride (NaCl) :
1) Sodium chloride is formed from the elements sodium (Na) and chlorine (Cl).
2) Cation formation:
i) When sodium (Na) atom loses one electron to get octet electron configuration, it forms a cation (Na+ ).
ii) Now Na+ gets electron configuration that of Neon (Ne) atom

3) Anion Formation :
i) Chlorine has shortage of one electron to get octet in its valence shell.
ii) So it gains the electron that was lost by Na to form anion and gets electron configuration of Argon (Ar).

4) Formation of NaCl :
i) Transfer of electrons between ‘Na’ and ‘Cl’ atoms, results in the formation of ‘Na+‘ and ‘Cl- ’ ions.
ii) These oppositely charged ions get attracted towards each other due to electrostatic forces and form the compound sodium chloride (NaCl). Na+(g) + Cl- (g) → Na+ Cl-(s) or NaCl
II. Formation of calcium oxide (CaO) :
1. Calcium (Ca) reacts with oxygen (0) to form an ionic compound calcium oxide (CaO).
2. Atomic number of Calcium is 20. Its electronic configuration is 2, 8, 8, 2.
3. 
4. Atomic number of Oxygen is 8. Its electronic configuration is 2, 6.
5. 
6. These oppositely charged ions get attracted towards each other due to electrostatic forces and form the compound calcium oxide (CaO). Ca2+ + O2- → Ca2+ O2- (or) CaO