Coordination number = Number of atoms or ions attached to the central atom
For ionic crystals: See how many opposite ions surround one ion in the crystal. Example- In NaCl: Each Na+ is surrounded by 6 Cl-. Hence, coordination number = 6
For molecule complexes: See the number of atoms directly bonded to the central atom. Ignore lone pairs and count only sigma bonds with atoms or ions. Example- In Fe(CN)6]3- the central atom = Fe3+, Ligands = 6 CN- (cyanide ions). Here, each CN- is directly bonded to Fe3+. Hence, coordination number = 6