Functions in C
Defining and composing functions, including static ones.
static int square(int x) {
return x * x;
}
static int sum_of_squares(int a, int b) {
return square(a) + square(b);
}
int hypotenuse_sq(int a, int b) {
return sum_of_squares(a, b);
}
How it works
staticlimits a function to this file.sum_of_squarescallssquaretwice.- The public function builds on the helpers.
Keywords and builtins used here
hypotenuse_sqintreturnsquarestaticsum_of_squares
The run, in numbers
- Lines
- 11
- Characters to type
- 183
- Tokens
- 56
- Three-star pace
- 90 tpm
At the three-star pace of 90 tokens a minute, this run takes about 37 seconds.
Step 1 of 7 in Functions, step 15 of 35 in Language basics.