5 bool leapyear(unsigned year) {
6 /* All years that are divisible by 4 are leap years,
7 unless they start a new century, provided they
8 are not divisible by 400. */
9 return !(year % 4) && ((year % 100) || !(year % 400));
10 }
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":1},{\"line\":0,\"ch\":2}],[{\"line\":0,\"ch\":19},{\"line\":0,\"ch\":27}],[{\"line\":1,\"ch\":1},{\"line\":1,\"ch\":2}],[{\"line\":2,\"ch\":1},{\"line\":2,\"ch\":2}],[{\"line\":3,\"ch\":1},{\"line\":3,\"ch\":2}],[{\"line\":4,\"ch\":1},{\"line\":4,\"ch\":2}],[{\"line\":4,\"ch\":7},{\"line\":4,\"ch\":13}],[{\"line\":4,\"ch\":38},{\"line\":4,\"ch\":40}],[{\"line\":5,\"ch\":0},{\"line\":5,\"ch\":2}]]"}
!@%STYLE%@!
`leapyear` receives an `unsigned` year, computes whether it is a leap year, and returns a `bool`. The code inside the braces is its definition. section 7.1
A function packages a computation so it can be called from elsewhere. A call such as `leapyear(2024)` supplies an argument; the function's parameter receives it. Library functions work the same way: `printf` accepts arguments that determine what it prints. TAKEAWAY: Put a feature in one function when it should be usable without copying its implementation. section 7.1 section 7.0
bool leapyear(unsigned year);
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":14},{\"line\":0,\"ch\":22}]]"}
!@%STYLE%@!
This declaration gives the compiler the function's interface without repeating its body: a `bool` return type and one `unsigned` parameter. section 7.1
Parentheses enclose parameter declarations in a declaration or definition, but arguments in a call. A function prototype specifies parameter types and a return type, letting the compiler check and, where appropriate, convert values at a call. Write `(void)` for a function with no parameters; use `void` as the return type when it returns no value. `main` is the program's entry point. section 7.1 section 7.0
Functions make data flow explicit through arguments and return types. They also reduce repeated code and the editing errors it invites. Each call has its own local variables, even when a function calls itself recursively. TAKEAWAY: separate local variables do not imply separate pointed-to data; recursive calls can still modify the same data through pointers. section 7.0 section 17.4



















