To refactor('function out') code:
-First select the portion of code to convert into function
-Mark out the required variables and use them as function parameters
-Replace the code with a function call after implementing your function
In C++, the compiler must see the function before it can be called hence the need for a prototype when the implementation is not 'available.'
1 2
//syntax for prototype:
return_value function_name(parameters);