after the star has been in the main sequence for a certain period of time hydrogen begins to run out o the outwardforce from nuclear fusion is less than the inwardgravity force
the star collapsesinwards causing the temp to increase making the heliumnuclei fuse creating heavierelements and he starts expands forming the red giant
eventually the red giant stops fusing heliumnuclei and the star shrinks forming the whitedwarf
since the white dwarf doesn’t carry out fusion it gradually coolsdown
finally it stopsreleasingenergy and forms the black dwarf