The density of which of the following will get affected by changing the temperature.
iron
water
CO2
Generally matters (solid, liquid and gases ) expand on heating and contract on cooling, expansion or contraction means a change in volume which will lead to change in density.
In solids, the expansion/contraction with change in temperature is less as compared to liquid and gases, so the density of solids doesn't change much.
But for liquids and gases, the expansion/contraction is more, so their volume changes leading to change in density as well.
If the volume increases the density decreases and if the volume decreases the density increases.