22.9k views
0 votes
Given two double variables, best value and second best value, write some code that swaps their values. declare any additional variables as necessary.

User Francois C
by
6.5k points

1 Answer

3 votes
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;
}
User Dima Vidmich
by
6.7k points