Water is the source of the hydrogen atoms in the sugars created by photosynthesis. Both water molecules and carbon dioxide molecules are broken down using energy from the sun and combined into sugar molecules containing carbon, hydrogen and oxygen.
The need for both carbon dioxide and water in plants creates complications for plants in hot, dry environments such as deserts. Plant leaves must be open to the atmosphere in order to take in carbon dioxide from the air, but this also allows water vapor to escape. Plants close tiny pores called stomata on their leaves to prevent this water loss during the hottest part of the day. If the closure continues for too long the leaves run out of carbon dioxide and photosynthesis stops.
In arid environments, plants develop ways to compensate for closing their stomata, so photosynthesis can continue longer. Some plants, such as crabgrass, add an extra step to their capture of carbon dioxide, which increases the efficiency greatly. These plants can continue photosynthesis even at very low carbon dioxide levels. Other plants, such as cacti, live in such dry environments that they can only open their stomata at night. These plants store carbon dioxide at night, then use it during the day.