Here we will first find out the gas. It is stated that this gas turns lime water milky so it is sure that the gas is carbon dioxide (CO2).
When CO2 reacts with water then carbonic aid is formed (H2CO3), which turns blue litmus red.
CO2 + H2O → H2CO3
When CO2 is passed through lime water (Ca(OH)2) it turns it milky and on excess passing of carbon dioxide it forms calcium bicarbonate which forms a colourless solution, so the reaction is:
Ca(OH)2 + CO2→ CaCO3 + H2O
On passing in an excess amount
CaCO3 + H2O + CO2→ Ca(HCO3)2
For the identification of substance X, we know that in product carbon dioxide is there so there must be something of carbon must be there in reactant and X is water-insoluble so it should be calcium carbonate that is insoluble.
So the reaction is:
CaCO3 + 2HCl → CaCl2 + H2O + CO2
X= CaCO3