The number of moles of a substance can be found from its mass. Use the relationship moles = mass (g) ÷ relative formula mass. For an element, use the relative atomic mass instead. It can be rearranged to mass = moles × relative formula mass. For example, the relative formula mass of sodium hydroxide, NaOH, is 40, so 8.0 g of it is 8.0 ÷ 40 = 0.2 mol.
The number of particles comes from the number of moles. Multiply the moles by the Avogadro constant, 6.02 × 1023, to find the number of particles. To go the other way, divide the number of particles by the Avogadro constant to find the moles. For example, 2 mol of water contains 2 × 6.02 × 1023 = 1.204 × 1024 molecules.
To find the number of particles in a given mass, work in two steps. First change the mass into moles, then multiply by the Avogadro constant. Carbon dioxide has a relative formula mass of 44, so 4.4 g is 0.1 mol. This contains 0.1 × 6.02 × 1023 = 6.02 × 1022 molecules. Check that your answer has a sensible number of significant figures, usually the same as the data in the question.