C/C++ Arena

Step 4 of 7

Prototypes

C reads your file top to bottom. If main calls a function that's defined below it, the compiler hasn't seen it yet. Fix that with a prototype: the function's first line followed by ;.

int triple(int x);        // prototype: "this exists"

int main(void) {
    printf("%d\n", triple(4));
}

int triple(int x) { return 3 * x; }   // definition

Your turn: press Check to see the error, then add the missing prototype.

Previous: void functions Next: Scope and pass by value