Answer:
Compasses are mainly used in navigation to find direction on the earth. This works because the Earth itself has a magnetic field which is similar to that of a bar magnet. The compass needle aligns with the Earth's magnetic field direction and points north-south. Also, In a magnet all the domains are oriented in the same direction. In the case of a nail, the domains can be aligned in the same direction causing the nail to become magnetic. That is because if you hang a bar magnet from a thread, the north pole will point to magnetic north. When you bring one north pole close to another north pole they repel each other. You can feel the two magnets pushing each other apart.