Answer:
Please refer to the figure.
Step-by-step explanation:
The crucial point here is to calculate the enclosed current. If the current I is flowing through the whole cross-sectional area of the wire, the current density is

The current density is constant for different parts of the wire. This idea is similar to that of the density of a glass of water is equal to the density of a whole bucket of water.
So,

This enclosed current is now to be used in Ampere’s Law.

Here,
represents the circular path of radius r. So we can replace the integral with the circumference of the path,
.
As a result, the magnetic field is
