Candide, distraught, makes his way to an inn in a neighboring town. There, he is tricked by two Bulgarian soldiers into joining their army. He is dragged off in chains, beaten, and forced to learn military exercises. He excels at these exercises, and is treated well for a while. However, he then makes the mistake of going for a walk, and is accused of desertion. He is asked if he would rather be whipped several thousand times or shot in the head. Choosing the first, he ends up begging for the second once the whipping begins. He is almost shot, but the King of the Bulgarians pardons him after learning that he is a philosophy student, and therefore ignorant about the world.
One of the institutional objects of Voltaire's scorn and criticism is the military. Rather than depicting soldiers as courageous and heroic, Voltaire depicts them as tricksters and bandits. And army life is so regimented and full of top-down control that even going for a walk can result in severe punishment. Voltaire also takes a swipe at philosophy here—often a knowledge of philosophy is treated as wisdom, but the Bulgarian king sees it as a reason to pity Candide for ignorance. The king sees philosophy as the opposite of wisdom and worldly understanding.