When black gunpowder explodes, potassium nitrate (KNO3), carbon, and sulfur react with each other to form nitrogen gas (N2), carbon dioxide gas (CO2), and solid potassium sulfide (K2S).

write the chemical equation

2 answers

a few seconds with google will provide the answer you seek.
Much faster than waiting around here.
16KNO3 (s) + 24C (s) + S8 (s) yield 8N2 (g) + 24CO2 (g) + 8K2S