You should read up on Proust's law, better known as the Law of Definite Proportions. This is a chemical law that defines your question more generally, on why the ratio of elements and ions are always fixed.
Basically, this compound Magnesium(II) Chloride is MgCl2 because it has the same number of protons, neutrons, and electrons all the way. This defines the properties of the compound or atom.
Answer: C(s) + O2(g) --> CO2(g)12g (C) .... 50.8g (O2)................. initial amounts0g(C) .........18.8g(O2) ................. amounts when reaction completeThat means that C was the limiting reactant, and the amount of CO2 is based on the amount of carbon that burned. Covert 12 grams of carbon to moles. The moles of CO2 will be the same, since they are in a 1:1 mole ratio. Then convert the moles of CO2 to grams.12g C x (1 mol C / 12.0 g C) x (1 mol CO2 / 1 mol C) x (44.0g CO2 / 1 mol CO2) =44 g of CO2