# Function seems to be a function but also declaring an integer?

I'm not in complete understanding of functions.

In the example below are they declaring an int. Or are they creating a
Function? Void setup is a function? Void loop too? Int myMultiplyFunction(int x , int y) is this too a function or are they declaring an int . I don't understand the int in front of it my multiply function , and I see it everywhere while decipher sketches.?
Can someone explain .
void setup(){
Serial.begin(9600);
}

void loop() {
int i = 2;j
int j = 3;
int k;

k = myMultiplyFunction(i, j); // k now contains 6
Serial.println(k);
delay(500);
}

int myMultiplyFunction(int x, int y){
int result;
result = x * y;
return result;
}

``````int myMultiplyFunction(int x, int y){
int result;
result = x * y;
return result;
}
``````

This declares a function that returns an int value and takes 2 ints, named x and y, as parameters.
result is declared as an int within the function and, after the calculation it is returned to the calling program.

By the way, I assume that this is just a typo and that the j is not meant to be there.

``````int i = 2;j
``````

To prevent overflows, the function should be more like

``````long myMultiplyFunction(int x, int y)
{
return ((long)x) * ((long)y);
}
``````

First, please read the two posts by Nick Gammon above on how to properly post to this Forum, especially the use of code tags when posting source code.

Second, some terms:

int myMultiplyFunction(int x, int y)
^ ^ ^
| | |
| | +-- Parameter list. May contain 0 or more variables that are
| | in some way used by the function.
| |
| |+--------------- Function name
|
+------------------------ Function type specifier. Tells the data type this function is
designed to return. This implies that the function body has
one (or more) statements that say return val, where val is an int.
The function type specifier may be void, in which case
nothing is returned from the function.

Sometimes you will see a line similar to the above near the top of a source code file, but with a semicolon at the end. This is called a function prototype and is used by the compiler for data type checking of the parameters as well as the return type.