The magnetic field causes deflection of the needle of a compass . The electric current causes a magnetic field around the wire due to which the compass needle moves.
A solenoid is an electric current-conducting coil of wire. An electromagnet built with a wire helical coil is known as a solenoid.
A magnetic field is created when an electric current is sent through the coil. When an electric current runs through a solenoid. It creates a magnetic field.
To learn more about the solenoid refer to the link ;
brainly.com/question/16015159