In the Core of a Star be it any type the pressure and temperature is high enough to squeeze atomic nuclei by initiating Nuclear Fusion. For instance Hydrogen nuclei fuse together to form Helium and from Helium to other heavier elements But the heavier the element the more the pressure and temperature required to fuse that element into a much heavier element.
in it’s main Sequence stage will burn Hydrogen into Helium and once it has no more hydrogen to burn it’ll burn Helium but Helium fusion requires much more density suggesting that the Sun will be much more denser in it’s Red Giant stage then the main sequence Stage. Even though the Sun in it’s Red Giant stage will be massive and much bigger it won’t burn heavier elements elements heavier then Carbon.
In much more massive Stars the pressure and temperature inside the core are very much higher then the Sun so this pressure allows more hydrogen to be fused very fast that is the reason why more massive stars tend to live a short lifetime. In contrast with the Sun massive stars much more massive then our Sun about 8 times the mass of our Sun after they burn all their helium into carbon can also burn that carbon into other heavier elements like Magnesium Neon and Sodium etc. and just not that they can also burn Magnesium into Oxygen Oxygen to Silicon and from Silicon to Iron. Fusion reaction Stops after the Star’s core is filled with Iron as Iron is the most Stable element.
After all this burning and Fusing higher mass Stars only tend to live for a few million years as they burn fuel much more faster then low mass Stars.