For non metals to attain a noble gas configuration, they gain the number of electrons needed to attain the noble gas configuration of the noble gas at the end of their periods. This means that these non metals would only take up the configuration of the last element on their periods which of course is always a noble gas.
The last element on the hydrogen period or more conservatively the only other element on the hydrogen period is helium, with an atomic number of 2. The atomic number is the number of protons in he nucleus of an atom. For an electrically neutral atom, the number of electrons equal the number of protons.
Hence we can deduce that helium has 2 electrons while hydrogen has one electron. Thus for it to attain the configuration of helium, it just needs to gain one more electron
Atomic number of carbon is 6. Thus, it has 6 electrons.
The electronic configuration of carbon is 1s2 2s2 2p2
Now, the inert gas closest to C is Ne, whose atomic number is 10.
Thus, there are excess of 4 electrons in Ne as compared to C.
Hence, carbon must gain 4 electrons to achieve noble-gas configuration.
Alternatively, C can also lose 4 electron to achieve noble gas configuration of He.
3 1/4 %