Functions and Modular Programming

Lesson 5 of 20

Package code into named, reusable blocks — parameters in, one value back out, and copies all the way down.

The big picture

Divide and conquer

Functions turn one big program into small named pieces you can call again and again — inputs arrive as parameters, one value comes back.

Functions

A named block you can call from anywhere. Write it once, reuse it forever.

Parameters

The named inputs a function declares — the caller sends arguments that fill them.

Return value

return sends one value back to the caller and ends the call immediately.

Copies, not originals

C passes arguments by value: a function works on copies, so the caller's variables never change.