I have really bad pain on my right rib cage I had a really bad cough but now is not as bad?

It may be a muscle . Strain from the coughing or even a rib fracture if the coughing was severe enough. It could also be an underlying lung problem that may need to be checked if you don't improve in terms of the pain.
Strained rib. The coughing irritated the rib and the attachements- it will be sore for a bit- . Ribs are best used to have on a bbq and not to cause pain in- so, stop coughing so hard and bbq more.