Skip to content

Your own functions

Read · 1 of 4

A function is a named recipe

int square(int x) { return x * x; } makes a function called square. It takes an int (called x inside) and gives back an int.

Write it above main. Calling square(5) runs it with x = 5 and the call turns into the returned value, 25.