Step-by-step explanation:
The chemical formula of an ionic compound can be written by using the symbols of the respective cations and anions.
The overall charge on the molecule should be zero.
Hence, the total charge of cations=total charge of anions.
The symbols of the given molecules are shown below:
sodium chloride ---- NaCl
magnesium chloride ---
calcium oxide ---- CaO
lithium phosphide----
aluminum sulfide -----
calcium nitride----