Assume you have a swap routine in place for doubles. Write a routine calls swap that reverses the entries in an array of doubles. Use this function declaration.

```
void reverse( double a, int size);
```
Carry out your reversal in place, do not make a local copy of the array
What will be an ideal response?


The answer is in bold face embedded in a complete test program.
```
#include const int SIZE = 10;
void swap(double& lhs, double& rhs){ double tmp =
lhs;
lhs = rhs;
rhs = tmp;
}

void reverse( double a[], int size)
{
using namespace std;

for (int i = 0; i < (size - 1)/2; i++)
swap(a[i], a[size - i - 1]);
}

int main()
{
using namespace std;
double foo[SIZE] = {0,1,2,3,4,5,6,7};for (int i = 0; i < SIZE; i++)
cout <<; foo[i] <<
cout < cout << foo[i],,
cout <<;
```

Computer Science & Information Technology

You might also like to view...

The Report Wizard button is found in the Reports group on the ________ tab

A) Home B) Create C) Database Tools D) External Data

Computer Science & Information Technology

Locking the controls on a form prevents them from being moved inadvertently as you work in the IDE.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology