Top-down programming For small programs, organizing a program into sequences, branches, and loops works well. But the larger your program gets, the harder it can be to view and understand the whole thing. So a second feature of structured programming involves breaking a large program into smaller parts where each part performs one specific task. This is also known as top-down programming. The idea behind top-down programming (as opposed to bottom-up programming) is that you design your program by identifying the main (top) task that you want your program to solve. For example, if you wanted to write a program that could predict the next winning lottery numbers, that is a top design of your program. Of course, you can’t just tell a computer, “Pick the next winning lottery numbers.”

You must divide this single (top) task into two or more smaller tasks. One of these smaller tasks might be, “Identify the lottery numbers that tend to appear often.” A second task might be, “Pick the six numbers that have appeared most often and display those as the potential future winning numbers.” The idea is that writing a large program may be tough, but writing a small pro- gram is easy. So if you keep dividing the tasks of your program into smaller and smaller parts, eventually you can write a small, simple program that can solve that task.
Then you can paste these small programs together like building blocks, and you’ll have a well-organized big program — theoretically. Now if you need to modify part of the large program, just find the small program that needs changing, modify it, and plug it back into the larger program, and you’ve just updated the larger program. Ideally, each small program should be small enough to fit on a single sheet of paper. This makes each small program easy to read, understand, and modify. When you divide a large program into smaller programs, each small program is a subprogram.