Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions