Defining and calling C functions, with parameters and return values explained visually.
int add(int a, int b) { return a + b; }return yields a valuevoid return and parametersint add(int a, int b) { return a + b; } int main(void) { int result = add(3, 5); printf("%d\n", result); // -> 8 }
intaddint a, int breturn a+b;| Name | Scope | Value |
|---|
max as minsum3(a, b, c)doubleCheck your understanding of this lesson!
void mean?void means "empty" — the function returns no value. The return statement can be omitted.
Variables in the function definition are called "parameters". Values passed at the call site are "arguments".
Variables declared inside a function are "local" and only exist within that function.
Combine this interactive site with books for more practice.
* Links above are affiliate links. Purchases help support this site.