(N/A) The figure shows the sectional view of a long solenoid. At various turns of the solenoid,the current comes out of the plane of the paper at points marked $\odot$ and enters the plane of the paper at points marked $\otimes$.
To determine the magnetic field $B$ at any point inside,consider a rectangular closed path $abcd$ as the Amperean loop.
According to Ampere's circuital law:
$\oint \overrightarrow{B} \cdot \overrightarrow{dl} = \int_{a}^{b} \overrightarrow{B} \cdot \overrightarrow{dl} + \int_{b}^{c} \overrightarrow{B} \cdot \overrightarrow{dl} + \int_{c}^{d} \overrightarrow{B} \cdot \overrightarrow{dl} + \int_{d}^{a} \overrightarrow{B} \cdot \overrightarrow{dl} \quad \dots(1)$
The $cd$ part is outside the solenoid. The magnetic field outside is zero,so $\int_{c}^{d} \overrightarrow{B} \cdot \overrightarrow{dl} = 0$. For the $bc$ and $da$ parts,the magnetic field is perpendicular to the path,so $\int_{b}^{c} \overrightarrow{B} \cdot \overrightarrow{dl} = \int_{d}^{a} \overrightarrow{B} \cdot \overrightarrow{dl} = 0$.
Thus,equation $(1)$ simplifies to:
$\oint \overrightarrow{B} \cdot \overrightarrow{dl} = \int_{a}^{b} \overrightarrow{B} \cdot \overrightarrow{dl} = \int_{a}^{b} B dl \cos 0^{\circ} = B \int_{a}^{b} dl = B h$
(Where $h$ is the length of part $ab$).
Suppose $n$ is the number of turns per unit length. The total number of turns in length $h$ is $nh$. If $I$ is the current in each turn,the total current enclosed by the loop is $I_{e} = I(nh) \quad \dots(2)$.
Applying Ampere's circuital law,$\oint \overrightarrow{B} \cdot \overrightarrow{dl} = \mu_{0} I_{e}$:
$Bh = \mu_{0} (nhI)$
$B = \mu_{0} nI$