The diatomic molecule can rotate about an axis at right angles to its own axis. Hence it has two degrees of freedom of rotational motion in addition to three degrees of freedom of translational motion along the three axes. So, a diatomic molecule has five degrees of freedom (Figure).
Examples: molecules of O2, N2, CO, Cl2 etc.