Well, to get you started with making the function:
1 2 3 4
|
int n(int x, int y)
{
}
|
So to break this down, you declare the return type of a function first before you name it (so in this case, int is the return type). Then you name the function after that (n is the name of the function, but you can change to whatever suits your boat).
Finally, you declare any parameters you want the function to take in. Let's start with understanding parameters: a parameter can be any type of variable (an int, float, or whatever) that you want a function to take in and use with itself. So, in this function I have declared two parameters (an int named 'x', and an int named 'y' (these names can be whatever you want)).
Now, you will need to do the math inside the function setting up a variable to store the value of 'x'. From there, you should multiply that variable against itself 'y' times. A simple way to do this involves using a for loop and setting the variable using '*=' which means it will equal itself * another value.
And that is pretty much all there is to it!