Specular reflectivity of neutrons and x rays can be used to determine the scattering length density profile of a material perpendicular to its surface. We have applied these techniques to study amorphous, diamondlike, hydrocarbon films. By the combination of these two techniques we obtain not only the mass density, but also the concentration of hydrogen, which varies in our case between 0 and 30 at.%. This method is a new and nondestructive way to determine the concentration of hydrogen within an error of less than 2 at.% in samples with sharp interfaces. It is especially suited for diamondlike carbon films.