As I say to any people requesting programming help on these forums, I always suggest that you include what language you're using in the question, otherwise you may not get the answer you're looking for.
Here's an example in C++, and note that I'm only showing the function, and not the entire code:
static void swap(double& one, double& two)
{
double temp = one;
one = two;
two = temp;
}