This is the origin of the 21-gun salute
If you ever attend a military funeral or memorial ceremony, you may notice a group of men and women proudly holding rifles. Then, at a specific time, they aim their weapons up to the sky and fire, usually causing a slight stir in the crowd, even though everyone was expecting it to happen.
Don't worry — those rounds are just blanks.
This practice is quite common throughout the world and, as with many traditions, it has a practical origin. Back when ships carried cannons, it was universally understood that immediately after firing, these weapons were rendered ineffective for a period of time — after all, reloading took a while. So, in order to demonstrate peaceful intent, ships would turn their cannons to the sky and discharge, telling those ashore that a ship's weapons weren't live.
https://www.wearethemighty.com/military-life/origin-21-gun-salute