In This Chapter
• Adding functions to programs
• Choosing between global and local variables
Typical computer programs are not the 20- to 30-line variety that you see in textbooks. In the “real world,” computer programs are much longer—but long programs contain lots of code that can get in the way while learning new concepts. That’s why, until this point, you’ve seen fairly short programs that contain all their code in
If you were to put an entire long program in
main(), you would spend a lot of time trying to find anything specific if you later needed to change it. This chapter is the first of three chapters that explore ways to partition your programs into sections via multiple functions. ...