Mass of carbon = 6g
We know that equal moles of all substances contain equal number of atoms (1 mole of all substances contains 6.022 × 1023 atoms).
The first step will be to convert 6g carbon into moles.
1 mole of carbon = 12g
12g carbon = 1 mole
Therefore, 6g carbon = 0.5 moles
Since, equal moles of all substances contain equal number of atoms, 0.5 moles of carbon will have the same number of atoms as present in 0.5 moles of magnesium.
The next step will be to find out the mass of 0.5 moles of magnesium in grams.
1 mole of magnesium = 24g
0.5 moles of magnesium = 24 × 0.5 = 12g
Hence, 12g magnesium will contain the same number of atoms as present in 6g carbon.