C++20 sections · 1024 units
Open in Course

Calling Functions

Running the code

Call a function by writing its name and passing values in parentheses. If add takes two integers, call with add(5, 3). The function runs and hands back a result you can store or use directly.

Example: int sum = add(10, 20); stores 30 in sum. Or skip the variable: cout << add(7, 8); prints 15 immediately. Every call is independent. Call add(2, 3) twice and the function runs twice with fresh values.

It doesn't remember previous calls.