Dear Student,
The atomic number of Carbon is 6 with electronic configuration as 2,4.
Thus in order to attain stability Carbon atom has to either gain 4 electrons or lose 4 electrons. But to its relatively smaller size the electrons are highly attracted to the nucleus and thus high energy is required to free the electrons from its outer shell. Also The strong repulsive forces due to the existing electrons makes it difficult to add four extra electrons to its outermost shell. Thus Carbon cannot form ionic compounds.
Carbon attains stability by mutually sharing its four electrons with other atoms. This type of bond formation by mutually sharing electrons is known as covalent bonding. Single bond, double bond and triple bond are the three types of covalent bonds.
Regards