Why We Need Control Constructs

Learn what control constructs are and why we need them.

Control constructs are statements that determine the flow of execution in a program, including conditionals (such as if statements), loops (like for and while loops), and branching statements (such as switch statements).We need control constructs because computational thinking gives us enough power to write a sequence of steps or recipes for doing any repetitive job. Suppose we need to determine the average of a finite set of different numbers. We might imagine doing this for 5, 6, or 10. However, when the list grows and reaches 100,000, it becomes impossible.

Computing the average without a loop

Suppose our application is programmed to take 100,000 inputs from a file with numbers stored in it. Can we enter them manually and see what the output will be?

Get hands-on with 1200+ tech skills courses.