Why do cheat codes work?

For non-gamers, cheat codes are passwords or button combinations that can be entered to trigger a particular effect or event within a video game . For example, a cheat code might replenish the ammunition in a weapon. It could also restore or increase a character's health.