When fired, the gunpowder burns out, forming hot gases that exert tremendous pressure. The gases do the job of increasing the kinetic energy of the flying bullet and the kinetic energy of the rifle during recoil, part of which is used to heat the barrel and generate a sound wave. All the rest of the energy remains in the heated gases that fly out after the bullet, and, in the end, is transferred to the molecules of the surrounding air.
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.