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
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 <<;
```
You might also like to view...
Copyright laws are used to help protect a company from __________.
a. computer fraud b. software piracy c. worms d. viruses e. plagiarism
The low level communication packet protocol for the Internet is ______.
Fill in the blank(s) with the appropriate word(s).
In a URL, folders and filenames are separated by ____.
A. slashes (/) B. backward slashes (\) C. asterisks (*) D. pound signs (#)
Identify UDP Header Fields and Operation Using a Wireshark TFTP Session Capture
Use Wireshark to capture a TFTP session and inspect the UDP header fields.