12 g of carbon and 24.3 g of magnesium, each contains 6.0221023 number of atoms.
Now
Let X g of carbon have 3.0111023 number of atoms.
Therefore,
So, 6 g of carbon contains 3.0111023 number of atoms.
Again,
Let X g of magnesium have 3.0111023 number of atoms.
Therefore,
So, 12 g of magnesium contains 3.0111023 number of atoms.
Hence, he will weigh 12 g of magnesium and 6 g of carbon.