Beginner level · Module 2 of 5 · 11 guided hours
Control Flow and Functions in C++
Make decisions and repeat work, then organise code into functions with value, reference and const reference parameters.
Learning objectives
- Use if/else, switch and loops correctly
- Write functions with parameters and return values
- Choose between pass by value, reference and const reference
Topics
- if/else and switch
- for, while, do-while and range-based for
- functions and declarations
- pass by value vs reference
- const reference
- function overloading
Lessons
-
Lesson 1 Decisions and Loops
Control what runs with if/else and switch, and repeat work with for, while and do-while loops.
if / else if / elseswitchfor and whileinfinite loop
-
Lesson 2 Writing Functions
Break programs into functions, declare them before use and return results.
function definitiondeclaration (prototype)return typeoverloading
-
Lesson 3 Passing by Value, Reference and const Reference
Understand how arguments are passed and choose the right form for speed and safety.
pass by valuereference parameter (&)const referencecopy cost
Practical activity
Build a school fee tracker that loops over students' payments and uses functions to classify each balance and total the arrears.
Expected outcomes
- Correct, readable control flow
- Programs organised into small functions
Assessment
Practical test with provided inputs: complete functions for classification and totals; marked on correctness and parameter choices.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.