Final answer:
When a star runs out of hydrogen, it becomes a red giant, begins helium burning, and then may expand into a red giant again before shedding its outer layers and leaving behind a white dwarf, neutron star, or black hole, depending on the star's core mass.
Step-by-step explanation:
When a star runs out of hydrogen, it no longer generates energy through hydrogen fusion. Consequently, the core begins to contract under gravity and heats up, leading to the expansion of the outer layers; the star becomes a red giant.
The core eventually becomes hot enough to start helium burning, fusing helium into carbon through the triple-alpha process. After a helium flash, the star briefly stabilizes, but as helium gets exhausted, the star expands into a red giant once again.
The star eventually sheds its outer layers, which may form a planetary nebula, and the core becomes a white dwarf, provided its mass is below Chandrasekhar's limit (approximately 1.4 solar masses).
For stars with core masses between 1.4 and about 3 solar masses, the outcome after these stages is the formation of a neutron star. Stars with core masses exceeding approximately 3 solar masses experience an even more dramatic fate, ultimately collapsing into a black hole.
The path a star takes through these stages varies based on its initial mass, with more massive stars evolving more rapidly through the stages of their life cycles.