Atoms only losing or gaining electrons give rise to electrically charged particles called ions. The positively charged ions are called cation, while the negatively charged ion is called anion. For example, if an atom A loses an electron, it gives A+ (a cation), and if an atom Been gains an electron, it gives B (an anion) i.e.,

A loss of an electron A+ + e

Positively charged ion (cation)

B + e gaining of an electron B

Negatively charged ion (anion)

Thus,

The number of electrons in a positive ion (cation) is less that in the atom.

And,

The number of electrons in a negative ion (anion) is more than that in the atom.

So, before writing the electronic configuration of an ion, you should first determine the total number of electrons with the ion. Then, these electrons are arranged in various energy levels (shells) as person Bohr-Bury scheme. For example, chlorine (atomic no 17) can accept one electron to form Cl . Then, the electronic configuration of Cl can be obtained as follows.

No. Of electrons in Cl atom= 17

No. of electrons in Cl ion= 17 +1 =18