Module 06 of 11

Functions & Scope

Lessons

About This Module

As programs grow, you stop writing everything inside main. Functions let you name a piece of logic, reuse it, and keep each part of a program small enough to understand. Every C program you read will be built from them.

The module starts with defining and calling functions, then covers arguments and return values and function prototypes, which tell the compiler what a function looks like before it is defined. It then looks at scope, the difference between local and global variables, and closes with recursion, where a function calls itself.

Watch the lessons in order, then continue on to Pointers & Memory Management.

Lessons

5 videos
01

Functions

The freeCodeCamp C course chapters on writing and calling your own functions, followed by the return statement. Starts at the 1:36:44 mark.

02

Function Arguments & Return Values

A beginner-friendly tutorial on passing data into functions with arguments and getting results back with return values.

03

Function Prototypes

How function prototypes work in C: declaring a function before main and defining it afterwards, with a worked example.

04

Local vs Global Variables

An explanation of local and global variables in C and how they differ, including variable scope and lifetime.

05

Recursion

An overview of how to use recursion in C, where a function calls itself, using the factorial function as the example.