Where did heavy chemical elements (carbon, oxygen, iron and others) come from in the Sun’s matter?

The synthesis of heavy elements occurred in the stars of the first generation, which then exploded and their matter went to the formation of stars of the second generation, including the Sun. Thermonuclear reactions in the Sun produce an insignificant amount of heavy elements.

Remember: The process of learning a person lasts a lifetime. The value of the same knowledge for different people may be different, it is determined by their individual characteristics and needs. Therefore, knowledge is always needed at any age and position.