Dear Gail, What you describe is most likely strained muscles in the rib cage secondary to coughing, especially since it gets better in certain positions. This usually responds to anti-inflammatories such as ibuprofen. Something to help relieve the cough may help as well if it is making it worse. Look for over the counter medicines with dextromethorphan to help with the cough. Occasionally stronger medicines like codeine are needed.
Treatment is as above.
Pneumonia can also cause sharp pain such as you have, but you would probably have a fever and feel very sick. If you experience shortness of breath or the pain worsens consult a physician right away. Most likely you have strained muscles and they will get better on their own as the coughing decreases. These are harmless keratin filled plugs in the skin and don't do any harm. These warts appear fleshy and bumpy, and may become quite large.