Question: Write a templated function doubleIt with one parameter and doubles the value by adding it to itself and returns the answer. doubleIt(3.5) should produce 7.0

Write a templated function doubleIt with one parameter and doubles the value by adding it to itself and returns the answer. doubleIt(3.5) should produce 7.0 doubleIt("hello") should produce "hellohello"

#include

using namespace std;

//Do not modify anything on or above the line below this //YOUR_CODE_BELOW

void sortDescending(int a[], int n) {

int i, j, m;

int tmp;

for (i = n-1; i > 0; i--)

{

m = i;

for (j = i-1; j >= 0; j--)

if (a[j] < a[m])

m = j;

tmp = a[m];

a[m]= a[i];

a[i]=tmp;

}

}

void sortDescending(char a[], int n)

{

int i, j, m;

char tmp;

for (i = n-1; i > 0; i--)

{

m = i;

for (j = i-1; j >= 0; j--)

if (a[j] < a[m])

m = j;

tmp = a[m];

a[m]= a[i];

a[i]=tmp;

}

}

//YOUR_CODE_ABOVE //Do not modify anything on or below the line above this int main() { cout << doubleIt(3.5) << endl;

//have to force type so "hello" not treated as char[] cout << doubleIt("hello") << endl;

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!