Magnets have the ability of attracting magnetic materials and attracting or repelling other magnets--making them perfect for inducing motion. Furthermore, their magnetism is also used to induce electricity. An electric current through magnetic material can also induce magnetism into it, making it a temporary magnet useful to perform many tasks. In computers, magnets have many uses.
(1) Data are stored in hard disk drives on the basis of magnetism.

(2) motor is an essential part of an electrical fan, and all motors contain magnets since they use magnetism and electricity to induce motion.

(3) Moving parts of computers like the lens and the eject mechanism of optical disc drives require motors to enable their motion and thus, involve the use of magnets since all motors operate using magnets.

(4) They are used in speakers and headphones to produce sounds ..
Hope it helped ! pLZ mark it as brainiest :)