The electric potential on the dipole axis for an electric dipole (where $\theta = 0$ or $\theta = \pi$) is given by:
The NCERT text states: 'From Eq. (2.15), potential on the dipole axis ($\theta = 0, \pi$) is given by $V = \pm \frac{1}{4\pi\epsilon_0} \frac{p}{r^2}$ (Eq. 2.16).' Here, for $\theta=0$, $\cos\theta=1$, so $V = \frac{1}{4\pi\epsilon_0} \frac{p}{r^2}$. For $\theta=\pi$, $\cos\theta=-1$, so $V = -\frac{1}{4\pi\epsilon_0} \frac{p}{r^2}$.