Digestion is the breakdown of carbohydrates to yield an energy rich compound called ATP. The production of ATP is achieved through the oxidation of glucose molecules. In oxidation, the electrons are stripped from a glucose molecule to reduce NAD+ and FAD. NAD+ and FAD possess a high energy potential to drive the production of ATP in the electron transport chain. ATP production occurs in the mitochondria of the cell. There are two methods of producing ATP: aerobic and anaerobic. In aerobic respiration, oxygen is required. Oxygen as a high-energy molecule  increases ATP production from 4 ATP molecules to about 30 ATP molecules. In anaerobic respiration, oxygen is not required. When oxygen is absent, the generation of ATP continues through fermentation. There are two types of fermentation: alcohol fermentation and lactic acid fermentation.
There are several different types of carbohydrates: polysaccharides (e.g., starch, amylopectin, glycogen, cellulose), monosaccharides (e.g., glucose, galactose, fructose, ribose) and the disaccharides (e.g., sucrose, maltose, lactose).
Glucose reacts with oxygen in the following reaction, C6H12O6 + 6O2 → 6CO2 + 6H2O. Carbon dioxide and water are waste products, and the overall reaction is exothermic because of the relative weak, high-energy double bond of O2.
Glycolysis, which means “sugar splitting,” is the initial process in the cellular respiration pathway. Glycolysis can be either an aerobic or anaerobic process. When oxygen is present, glycolysis continues along the aerobic respiration pathway. If oxygen is not present, then ATP production is restricted to anaerobic respiration. The location where glycolysis, aerobic or anaerobic, occurs is in the cytosol of the cell. In glycolysis, a six-carbon glucose molecule is split into two three-carbon molecules called pyruvate. These carbon molecules are oxidized into NADH and ATP. For the glucose molecule to oxidize into pyruvate, an input of ATP molecules is required. This is known as the investment phase, in which a total of two ATP molecules are consumed. At the end of glycolysis, the total yield of ATP is four molecules, but the net gain is two ATP molecules. Even though ATP is synthesized, the two ATP molecules produced are few compared to the second and third pathways, Krebs cycle and oxidative phosphorylation. 
Even if there is no oxygen present, glycolysis can continue to generate ATP. However, for glycolysis to continue to produce ATP, there must be NAD+ present, which is responsible for oxidizing glucose. This is achieved by recycling NADH back to NAD+. When NAD+ is reduced to NADH, the electrons from NADH are eventually transferred to a separate organic molecule, transforming NADH back to NAD+. This process of renewing the supply of NAD+ is called fermentation, which falls into two categories.
In alcohol fermentation, when a glucose molecule is oxidized, ethanol (ethyl alcohol) and carbon dioxide are byproducts. The organic molecule that is responsible for renewing the NAD+ supply in this type of fermentation is the pyruvate from glycolysis. Each pyruvate releases a carbon dioxide molecule, turning into acetaldehyde. The acetaldehyde is then reduced by the NADH produced from glycolysis, forming the alcohol waste product, ethanol, and forming NAD+, thereby replenishing its supply for glycolysis to continue producing ATP.
Lactic Acid Fermentation
In lactic acid fermentation, each pyruvate molecule is directly reduced by NADH. The only byproduct from this type of fermentation is lactate. Lactic acid fermentation is used by human muscle cells as a means of generating ATP during strenuous exercise where oxygen consumption is higher than the supplied oxygen. As this process progresses, the surplus of lactate is brought to the liver, which converts it back to pyruvate.
The Citric acid cycle (also known as the Krebs cycle)
If oxygen is present, then following glycolysis, the two pyruvate molecules are brought into the mitochondrion itself to go through the Krebs cycle. In this cycle, the pyruvate molecules from glycolysis are further broken down to harness the remaining energy. Each pyruvate goes through a series of reactions that converts it to acetyl coenzyme A. From here, only the acetyl group participates in the Krebs cycle—in which it goes through a series of redox reactions, catalyzed by enzymes, to further harness the energy from the acetyl group. The energy from the acetyl group, in the form of electrons, is used to reduce NAD+ and FAD to NADH and FADH2, respectively. NADH and FADH2 contain the stored energy harnessed from the initial glucose molecule and is used in the electron transport chain where the bulk of the ATP is produced.
The last process in aerobic respiration is oxidative phosphorylation, also known as the electron transport chain. Here NADH and FADH2 deliver their electrons to oxygen and protons at the inner membranes of the mitochondrion, facilitating the production of ATP. Oxidative phosphorylation contributes the majority of the ATP produced, compared to glycolysis and the Krebs cycle. While the ATP count is glycolysis and the Krebs cycle is two ATP molecules, the electron transport chain contributes, at most, twenty-eight ATP molecules. A contributing factor is due to the energy potentials of NADH and FADH2. As they are brought from the initial process, glycolysis, to the electron transport chain, they unlock the energy stored in the relatively weak double bonds of O2. A second contributing factor is that cristae, the inner membranes of mitochondria, increase the surface area and therefore the amount of proteins in the membrane that assist in the synthesis of ATP. Along the electron transport chain, there are separate compartments, each with their own concentration gradient of H + ions, which are the power source of ATP synthesis. To convert ADP to ATP, energy must be provided. That energy is provided by the H+ gradient. On one side of the membrane compartment, there is a high concentration of H+ ions compared to the other. The shuttling of H+ to one side of the membrane is driven by the exergonic flow of electrons throughout the membrane. These electrons are supplied by NADH and FADH2 as they transfer their potential energy. Once the H+ concentration gradient is established, a proton-motive force is established, which provides the energy to convert ADP to ATP. The H+ ions that were initially forced to one side of the mitochondrion membrane now naturally flow through a membrane protein called ATP synthase, a protein that converts ADP to ATP with the help of H+ ions. 
- Weiss, H. M. (2008). "Appreciating Oxygen" J. Chem. Educ. 85: 1218-1219.
- Schmidt-Rohr, K. (2020). "Oxygen Is the High-Energy Molecule Powering Complex Multicellular Life: Fundamental Corrections to Traditional Bioenergetics” ACS Omega 5: 2221-2233. http://dx.doi.org/10.1021/acsomega.9b03352
- Reece, Jane; Urry, Lisa; Cain, Michael; Wasserman, Steven; Minorsky, Peter; Jackson, Robert (2011). Campbell biology / Jane B. Reece ... [et al.] (9th ed.). Boston: Benjamin Cummings. pp. 164–181. ISBN 978-0321558237.