The first electron shell can contain up to 2 electrons; the 2nd and 3rd
shells can contain up to 8 electrons each.
Carbon has 4 valence electrons: 4 electrons in its outermost (valence) shell.
An atom is most stable when its valence shell is filled with the maximum number of electrons.