Atoms of different elements join together in definite proportions to form molecules of compounds. Compounds can be either ionic compounds or molecular compounds.
Ionic compounds are those compounds that contain charged species of metals and nonmetals.
The charged species are known as ions.
An ion is a charged particle and can be negatively or positively charged.
A negatively charged ion is called an anion and the positively charged ion is called cation.
Ionic compounds are formed when ionic bonds are formed between different elements through transfer of electrons.
Examples of ionic compounds - sodium chloride, calcium oxide.
Molecular compounds or covalent compounds are those compounds in which the elements share electrons via covalent bonds.
Examples - water, ammonia, carbon dioxide.