What happens to a stock when a company is sold, or goes bankrupt?

JOKER23 asked: For example, i bought a stock and the company went bankrupt, what happens to my stock? i also want to know what happens to a stock when a company is sold to another company, for example bellsouth.