The Sun's enormous mass is held together by gravitational attraction, producing immense pressure and temperature at its core. The Sun has six regions: the core, the radiative zone, and the convective zone in the interior; the visible surface, called the photosphere; the chromosphere; and the outermost region, the corona.
At the core, the temperature is about 15 million degrees Celsius), which is sufficient to sustain thermonuclear fusion. This is a process in which atoms combine to form larger atoms and in the process release staggering amounts of energy. Specifically, in the Sun’s core, hydrogen atoms fuse to make helium.
The energy produced in the core powers the Sun and produces all the heat and light the Sun emits. Energy from the core is carried outward by radiation, which bounces around the radiative zone, taking about 170,000 years to get from the core to the top of the convective zone.
The temperature drops below 2 million degrees Celsius in the convective zone, where large bubbles of hot plasma (a soup of ionized atoms) move upwards.
The surface of the Sun, the part we can see, is about 5,500 degrees Celsius. That's much cooler than the blazing core, but it's still hot enough to make carbon, like diamonds and graphite, not just melt, but boil.