To prevent a cake from sticking to the pan, grease the pan with butter or cooking spray, and then dust it with flour. You can also line the bottom of the pan with parchment paper.