basics · beginner · ~15 min

Triple a value

Implement a function matching a declared prototype.

Challenge

Provide the implementation that matches a prototype a header would declare.

Task

Header files declare functions that other source files implement. Implement int triple(int n) that returns 3 * n, matching its declared prototype. No main — the grader calls it.

Input

A single int n.

Output

Returns 3 * n, as an int.

Example

triple(3)    ->   9
triple(0)    ->   0
triple(-2)   ->   -6

Edge cases

  • Negative and zero inputs work as expected.

Input format

A single int n.

Output format

3 * n, as an int.

Starter code

int triple(int n) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.