Unit 5: Control Structures
Control structures dictate how a program will behave under certain circumstances. Control structures belong to one of two families: those that test values and determine what code will be executed based on those values, and those that loop, performing identical operations multiple times. Control structures like if-then-else and switch the program to behave differently based on the data that they are fed. The while and for loops allow you to repeat a block of code as often as it is needed. As you will see, that functionality can be very useful when designing complex programs.
This unit will introduce you to control structures and how they are used before moving on to discuss if, switch, while/do-while, and for loops. We will also discuss some advanced topics, such as nesting and scope. By the end of this unit, you should be able to draw from the information you learned in the previous unit to create a control structure, which will allow you to create more involved and useful programs.
Completing this unit should take you approximately 10 hours.
5.1: Introduction to Control Structures
5.2: The 'if' statement
5.3: The 'switch' Statement
5.4: The 'while' and 'do-while' Loops
5.5: The 'for' Loop
5.6: Advanced Topics
Unit 5 Assessment