An alveolus (plural: alveoli) is a tiny air sac of the lung. This is the site of gas exchange. They are located at the ends of the air passageways in the lungs.
Air enters the lungs during inhalation. This air has a high concentration of oxygen. This oxygen-rich air enters the alveolus.
The concentration of oxygen is higher in the alveolus than in the red blood cells. Therefore, the oxygen diffuses into the blood of the capillary running near the alveolus.
The concentration of carbon dioxide is higher in the blood than in the alveolus. Therefore, carbon dioxide diffuses from the capillary into the alveolus.
Carbon dioxide is then removed from the body during exhalation.
Alveoli are adapted for their function. They are only one-cell thick and allow easy exchange of gases as the diffusion distance is very short.
Also, an average human lung has approximately 480 million alveoli and they are surrounded by a large capillary network. This allows maximum gas exchange as there is a large surface area.