The mass of an atom of any natural element is taken as the average mass of all the naturally-occurring atoms of that element. If an element has no isotopes, then the mass of its atom would be the same as the sum of the protons and neutrons in it. But if an element occurs in isotopic forms, then we have to know the percentage of each isotopic form and then calculate the average mass.
Therefore, the masses of certain elements are in fractions and not whole numbers.