Solution :
We all know that a bar magnet have two poles, the north pole and the south pole. These poles interacts with each other. The ends of the magnets having similar poles will push each other away while the poles with like charges will pull each others towards it.
The compass needle is also a magnet having south polarity as well as north polarity. When the compass needle is close to the bar magnet, it is opposite to the poles or along the poles. The compass needle shows the direction or is pointed towards the north. So when the compass needle is placed near the north pole of the bar magnet, the pointer of the compass needle points towards the north, i.e. it gets deflected because of he like charges. And when it is placed near the south pole of the magnet, it gets attracted towards it and is pointed towards the pole.
Now as we move the compass needle from the poles to the region that is between the poles, the compass needle pointer points towards the north direction every time. It show a deflection always. If we place the magnetic lines, we will see that the magnetic lines will exit from the north poles and enters the south pole of the bar magnet.