C/C++ Arena

Step 1 of 7

Define and call a function

A function packages code under a name. It has a return type, a name, parameters, and a body:

int square(int x) {
    return x * x;
}

You call it like square(7), which evaluates to 49.

From now on, some steps are function steps: you write only the function, and hidden tests call it with different inputs. Don't write main on those steps.

Your turn: complete add so it returns the sum of its two parameters.

Next: Write a function