The atomic mass of carbon, or any other element, is primarily determined by adding the number of protons and the number of neutrons in the nucleus of an atom. The electrons have negligible mass compared to protons and neutrons, so they do not significantly contribute to the atomic mass.
Therefore, the correct answer is:
B) By adding the number of protons and the number of neutrons.