A carbohydrate is an organic compound
Organic compound
An organic compound is any member of a large class of gaseous, liquid, or solid chemical compounds whose molecules contain carbon. For historical reasons discussed below, a few types of carbon-containing compounds such as carbides, carbonates, simple oxides of carbon, and cyanides, as well as the...

 with the empirical formula (where m could be different from n); that is, consists only of carbon
Carbon is the chemical element with symbol C and atomic number 6. As a member of group 14 on the periodic table, it is nonmetallic and tetravalent—making four electrons available to form covalent chemical bonds...

, hydrogen
Hydrogen is the chemical element with atomic number 1. It is represented by the symbol H. With an average atomic weight of , hydrogen is the lightest and most abundant chemical element, constituting roughly 75% of the Universe's chemical elemental mass. Stars in the main sequence are mainly...

, and oxygen
Oxygen is the element with atomic number 8 and represented by the symbol O. Its name derives from the Greek roots ὀξύς and -γενής , because at the time of naming, it was mistakenly thought that all acids required oxygen in their composition...

, with a hydrogen:oxygen atom
The atom is a basic unit of matter that consists of a dense central nucleus surrounded by a cloud of negatively charged electrons. The atomic nucleus contains a mix of positively charged protons and electrically neutral neutrons...

 ratio of 2:1 (as in water
Water is a chemical substance with the chemical formula H2O. A water molecule contains one oxygen and two hydrogen atoms connected by covalent bonds. Water is a liquid at ambient conditions, but it often co-exists on Earth with its solid state, ice, and gaseous state . Water also exists in a...

). However, there are exceptions to this. One common example would be deoxyribose
Deoxyribose, more, precisely 2-deoxyribose, is a monosaccharide with idealized formula H---3-H. Its name indicates that it is a deoxy sugar, meaning that it is derived from the sugar ribose by loss of an oxygen atom...

, a component of DNA, which has the empirical formula C5H10O4. Carbohydrates can be viewed as hydrate
Hydrate is a term used in inorganic chemistry and organic chemistry to indicate that a substance contains water. The chemical state of the water varies widely between hydrates, some of which were so labeled before their chemical structure was understood....

s of carbon, hence their name.