A bar magnet is placed near and lying along the axis of a solenoid connected…