Coral reefs take part in the carbon cycle, which is awesome! This is where Carbon, in the form of CO2, comes from the atmosphere and is assimilated by a plant or algae containing chlorophyll. From here, the carbon will usually get converted into carbohydrates using energy from the sun (which is really convienent because coral reefs are typically shallow in tropical regions, where there is a lot of sunlight).
The carbohydrates are there in the ocean until the plant gets eaten by some organism. This next part of the cycle can take a while to complete. If the organism is eaten by another one (predator and prey), then the carbon just transfers over. Eventually, the carbon will either be dissolved into the ocean water to be assimilated by another plant OR the carbon makes its way back into the atmosphere. And the cycle will begin again and again and again.
Image Source: Maragos, J (27 Mar. 2011). Coral Reef at Palmyra Atoll National Wildlife Refuge. Retrieved from https://commons.wikimedia.org.
Source: Jury, C. The Nutrient Dynamics of Coral Reefs: Part I, Biogeochemical Cycles. Reefkeeping. Retrieved from http://reefkeeping.com/issues/2006-08/cj/index.php.