← The C Language Lesson 25 of 77 · 5 XP

Warm-up: the square function warm-up

Theory and problem statement

Machine translation, not yet reviewed by a native speaker.

A function in C is a result type, a name, parameters in brackets and a body. return gives back the answer:

int twice(int x)
{
    return x * 2;
}

The function is written before main and called inside it: twice(5) gives 10.

Task. Finish the function int square(int x) that returns the square of a number. main already reads the number and prints square(n).

Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.