Not only can you give values to a function, you can get a value back as well.  All functions have a ‘return type’, and so far the only return type we’ve used is called ‘void’. Void is a special return type meaning ‘nothing to return’, but we can exchange this for a different type:

int myFunction() Declares a function that takes no parameters, and returns an int value.
bool myFunction(int a) Declares a function that takes one parameter of type int, named a, and returns a boolean value.
string myFunction(int a, bool b) Declares a function that takes 2 parameters, one of type int named a, the other of type bool named b, and returns a value of type string.
void myFunction() Declares a function that takes no parameters and returns no value.

If our function isn’t of type void, then we must use the keyword 'return' within the function to state at what point to return the value, and what the value is.  For example, this function takes an integer as a parameter and returns its square (the number multiplied by itself):

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

Here is a function that takes a temperature in degrees centigrade and returns a string representing how water behaves at that temperature.

string water(int temp)
{
if( temp < 0 ) return "ice";
if( temp < 100) return "liquid";
else return "steam";
}

The program given to you asks the user for a number, and whether they would like to square or cube the number. 

Tasks: