To calculate the molecular mass of a compound, you need to know two things. The first is the molecular formula, and the second is the atomic mass number of each of the elements that comprise it. The atomic mass number for each element is listed in atomic mass units under its symbol in the periodic table. This unit is defined in such a way that the mass number of each element corresponds to the mass of one mole of the element in grams. A mole equals Avogadro's number (6.02 x 1023) of atoms or molecules.
TL;DR (Too Long; Didn't Read)
To find the mass of one mole of a specific molecule, add the atomic masses of each of its component atoms. You can look these up in the periodic table.
The Molecular Formula
Atoms combine in various ways according to the number of electrons each has in its outer shell. Ionic compounds, such as sodium chloride (NaCl), may be composed of only one atom each of two different elements, and some covalent gases, such as hydrogen (H2) and oxygen (O2) are composed of two atoms of the same element. Some molecules, particularly those that form with carbon, can have a very large number of component atoms. For example, glucose (C6H12O6) has 24 individual atoms.
No matter how large or small the molecule, the procedure for calculating its molecular mass is the same. You look up the atomic mass of each of the elements in the formula, multiply it by the number of atoms of that element in the compound and add it to all the others. This gives you the mass, in grams, of one mole of the molecule.
Looking up Atomic Mass Numbers
All the elements are arranged in the periodic table according to increasing atomic number, which corresponds to the number of protons in the nucleus. Hydrogen has one proton, so it comes first, while oxygen has eight protons, so it's eighth. Atomic number is not the same as atomic mass, however, because you also have to add the mass of the neutrons in the nucleus. Electrons are so small and light that their weight is considered negligible. The atomic mass, being the sum of all protons and neutrons, is listed under the symbol for each element.
Round to the Nearest Integer: Atomic mass numbers usually include a decimal fraction. This is because each element has one or more naturally occurring isotopes, which are versions that contain one or more extra neutrons or are missing one or more. The mass number takes all these isotopes into consideration, but for most practical purposes, you don't need to do that. So you usually round the mass number to the nearest integer. For example, the periodic table lists the atomic mass number of oxygen as 15.999. For most practical purposes, you can round this to 16. The mass number tells you that one mole of oxygen has a mass of 16 grams.
What is the molecular mass of glucose in grams?
The chemical formula of glucose is C6H12O6. The periodic table tells you that the atomic mass of carbon (C) is 12, that of hydrogen (H) is 1 and that of oxygen (O) is 16. The glucose molecule has 6 carbons, 12 hydrogens and 6 oxygens, so its molecular mass is (6 • 12) + (12 • 1) + (6 • 16) = 180. Therefore, one mole of glucose has a mass of 180 grams. If you want to find the mass of more than one mole, multiply the amount in grams by the number of moles.