When anything irritates your throat or airways, your body responds with a cough. The reflex to cough comes from an impulse in your brain to push air out of your lungs and drive out whatever may be irritating you.
Coughing sometimes is quite natural and healthy. A cough that lasts for several weeks or produces yellow or bloody mucus may signal a medical problem that requires treatment. Coughing for an extended period might irritate the lungs and lead to additional health problems such as insomnia, dizziness or fainting, migraines, and vomiting. Long-term, vigorous coughing can even lead to broken ribs.
If your cough hasn’t cleared up within a couple of weeks, or if it brings up blood or mucus, talk to a doctor right away. In these cases, the cough could be a sign of a more serious underlying medical condition.