1. Stellar evolution ↑
When stars run out of hydrogen to fuse in their cores, stars below about 10 times the mass of the Sun become red giants and then white dwarfs. More massive stars will become supergiants, and then undergo a supernova, becoming either a neutron star or a black hole.
Stellar Evolution. Image credit: NASA/CXC/M.Weiss/Public domain.
2. Red giants ↑
When the Sun runs out of hydrogen to fuse in its core, it will no longer produce enough nuclear energy to counterbalance the force of gravity, and so it will contract slightly. This will cause it to increase in temperature, and allow hydrogen fusion to begin in the shell around the helium core.
Fusion creates extra radiation pressure, and this will cause the Sun to expand. The outer layers of hydrogen will decrease in temperature, which will make them redder, and the Sun will then be a red giant.
Diagram showing the evolution of a Sun-like star, from protostar to red giant. After this, the core will become a white dwarf, while the outer layers will form a planetary nebula. Image credit: ESO/M. Kornmesser/CC-A.
The helium core of a red giant is so dense that it becomes degenerate. This means that it's as dense as the Pauli exclusion principle allows, and won't be able to change in size as it changes in temperature.
It cannot expand and cool when it is heated by the hydrogen fusion in the shell around it, and eventually it gets so hot that the helium nuclei began to fuse into carbon via the triple alpha process. The carbon can then fuse with helium nuclei to become oxygen and neon.
In stars less than about 2.5 times the mass of the Sun, this process is known as a 'helium flash'. This is because helium fusion occurs in a matter of minutes to hours. The energy released by the helium flash means that the star becomes so hot that it stops being degenerate, it can then expand and cool. These stars are sometimes called horizontal branch stars.
When all the helium has been fused into other elements, radiation pressure decreases, and the star contracts again under gravitation. Much higher temperatures are needed for carbon and oxygen fusion to begin, and so this only occurs in stars over about 10 times the mass of the Sun.
Stars less than about 10 times the mass of the Sun become asymptotic-giant branch stars - red giants with inert, degenerate carbon/oxygen cores, which are fusing helium in the shell around the core. This helium fusion causes the star to become unstable and the envelope is ejected as a planetary nebula.
If the remaining core is less than about 1.4 times the mass of the Sun, then it becomes a white dwarf. If it is more than about 1.4 times the mass of the Sun, then it becomes a neutron star or black hole.
Planetary Nebula: Cat's Eye Nebula. Image credit: J.P. Harrington and K.J. Borkowski (University of Maryland) and NASA/ESA/CC-A.
Planetary Nebula: Eskimo Nebula. Image credit: NASA/Andrew Fruchter (STScI)/Public domain.
Planetary Nebula: Ring Nebula. Image credit: NASA/Hubble Heritage Team/Public domain.
2.1 The triple alpha process ↑
Helium fuses into carbon via the triple alpha process. Here two helium nuclei (made of two protons and two neutrons) collide to produce a gamma ray, and a beryllium nucleus (made of four protons and four neutrons). This decays into a carbon nucleus (made of six protons and six neutrons), a helium nucleus, and a gamma ray.
If the carbon nucleus collides with another helium nucleus, it will produce an oxygen nucleus. Neon nuclei are formed if oxygen nuclei fuse with another helium nucleus.
3. White dwarfs ↑
White dwarfs are extremely dense because they are no longer producing nuclear energy to counterbalance the force of gravity. They are prevented from collapsing completely due to electron degeneracy.
White dwarfs are about half as massive as the Sun, but are not much bigger than the Earth. They have a very thin hydrogen and helium atmosphere, and a crust that is about 50 km thick. It's thought that there's a crystalline lattice of carbon and oxygen below this.
White dwarfs, image from the Hubble Space Telescope. Image credit: NASA and H. Richer (University of British Columbia)/Public domain.
The size of the Earth and a white dwarf to scale. Image credit: modified by Helen Klus, original image by NASA/Public domain.
If a white dwarf is part of a binary system - and at least half of all stars are in binaries because stars are formed close to each other - then the crust may be stripped away, exposing the core. This is what's happened to PSR J1719-1438 b, which is known as a diamond planet.
When a white dwarf stops producing light, it's known as a black dwarf. White dwarfs are expected to keep radiating for well over 14 billion years, however, and so the universe is not yet old enough to contain any.
If a white dwarf is part of a binary system, it may acquire mass from its companion. This extra mass increases the white dwarfs' temperature but, because it's degenerate, it can't expand and cool. It can get so hot that carbon and oxygen begin fusing extremely quickly, creating explosions on the surface. This may release so much energy that it explodes in a Type Ia supernova (also known as a thermal runaway supernova), and ejects its companion into space.