An atom of carbon always has 6 protons and typically has 6 neutrons. Oxygen has 8 protons and typically 8 neutrons. So a molecule of CO2 masses very nearly 16+16+12 for every 12 that pure carbon masses.
Gasoline is not pure carbon, of course, because the gasoline is composed of carbon and hydrogen. The hydrogen ends up in water molecules and does not contribute to CO2, but then again, it was so light that it contributed little to the mass of the gasoline in the first place.