The respiratory system functions to supply oxygen to tissues and remove carbon dioxide. It includes the nose, pharynx, larynx, trachea, bronchi, bronchioles and lungs. During inhalation, the diaphragm contracts and the thoracic cavity expands, causing air to flow into the lungs. During exhalation, the diaphragm relaxes and air flows out. Gas exchange occurs in the alveoli where oxygen diffuses into blood and carbon dioxide diffuses out. External respiration is the exchange of gases between the lungs and blood, while internal respiration is the exchange between blood and tissues.