I'm 38 weeks pregnant and have cold/cough/no fever/ baby ok. I'm on z pack. I need to cough but have sharp pain in right side when I do. What can I do?

Cough & pregnancy. Your cough could be due to upper respiratory infection, acid reflux, postnasal drip, etc. Identify the cause, and try treating it. Most cough medicines are not recommended during pregnancy. But could certainly try saline nasal rinsing. If acid reflux is causing cough, you may want to avoid food triggers. Zantac is category b, and you could consider taking it. Check with your doctor.
Likely pulled muscle. It sounds that you may have a "pulled/strained muscle" that is attaching to your ribs etc...If no pain except when moving/coughing, this is likely the case. If it is there all the time, get checked out. Tylenol, (acetaminophen) topical muscle-rubs/icy-hot etc.., capsaicin cream etc...May help...If not better, consult doc...Congrats on pregnancy and good luck with the upcoming delivery!