Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Source File: /2336/20/1ab20.cpp Input: Output: Value: under control of main function under control of main function Write a function template whose prototype is given by
Source File: /2336/20/1ab20.cpp Input: Output: Value: under control of main function under control of main function Write a function template whose prototype is given by : template e void mySwap (T& first, T& second); The function swaps the contents of first and second. Write a second function template that is recursive and whose prototype is given by template 2 #include 4 using namespace std; e I/ function template prototypes 7 templatectypename T s void mySwap (T& first, T& second); 9 templatectypename T o void bubbleSort (T array, int n); 12 #include "lab20 . cpp" 4 template s void printArray(const *array, int count) 7if (count > 0) cout cd 2336 2 newuserQcsunix /2336>./getlab.ksh 20 3 * Checking to see if a folder exists for Lab 20No *Creating a folder for Lab 20 Checking to see if Lab 20 has sample input and output files. . .Yes Copying input and output files for Lab 20 from folder /usr/local/2336/data/20 to folder ./20 Checking to Copying file /usr/local/2336/src/1ab20main.C to folder ./20 Checking to see if /usr/local/2336/include/1ab20.h exists. . .No s * see if /usr/local/2336/src/1ab20main . C exists. .Yes . 41Copying file /usr/local/2336/src/Makefile to folder ./20 12Adding a target of lab20main to targetsisrcfile 13Touching file ./20/1ab20.cpp 4Edit file ./20/lab20.cpp in Notepad++ s newuser@csunix /2336> cd 20 newuser@csunix "/2336/20> 1s 01.dat 18 newuser@csunix /2336/20> make lab20main 9 g++ -g -Wall-std-c++11lab20main.c -I/usr/local/2336/include -I 20 g++-o lab20main lab20main.o -L/usr/local/2336/1ib -1m-1bits 21 newuserQcsunix /2336/20 /1ab20main 22 Array a contains: 23 5 4 3 21 24 1 2 3 45 as Array b contains 26 7.7 6.6 5.5 4.4 3.3 2.2 1.1 2 1.1 2.2 3.3 4.4 5.5 6.6 7.7 28 Array c contains: 2 HEL L O 30 E HLL O 1Array d contains: 32 Cadillac Oldsmobile Chevrolet Toyota Lexus Dodge GMC BMw 3 BMW Cadillac Chevrolet Dodge GMC Lexus Oldsmobile Toyota s4 newuser csunix /2336/20> ./lab20main > my.out s newuser csunix /2336/20> diff 01.out my.out 3 newuser@csunix /2336/20> 01.out Makefile lab20.cpp b20main.c Figure 2. Commands to Compile, Link, & Run Lab 20 Source File: /2336/20/1ab20.cpp Input: Output: Value: under control of main function under control of main function Write a function template whose prototype is given by : template e void mySwap (T& first, T& second); The function swaps the contents of first and second. Write a second function template that is recursive and whose prototype is given by template 2 #include 4 using namespace std; e I/ function template prototypes 7 templatectypename T s void mySwap (T& first, T& second); 9 templatectypename T o void bubbleSort (T array, int n); 12 #include "lab20 . cpp" 4 template s void printArray(const *array, int count) 7if (count > 0) cout cd 2336 2 newuserQcsunix /2336>./getlab.ksh 20 3 * Checking to see if a folder exists for Lab 20No *Creating a folder for Lab 20 Checking to see if Lab 20 has sample input and output files. . .Yes Copying input and output files for Lab 20 from folder /usr/local/2336/data/20 to folder ./20 Checking to Copying file /usr/local/2336/src/1ab20main.C to folder ./20 Checking to see if /usr/local/2336/include/1ab20.h exists. . .No s * see if /usr/local/2336/src/1ab20main . C exists. .Yes . 41Copying file /usr/local/2336/src/Makefile to folder ./20 12Adding a target of lab20main to targetsisrcfile 13Touching file ./20/1ab20.cpp 4Edit file ./20/lab20.cpp in Notepad++ s newuser@csunix /2336> cd 20 newuser@csunix "/2336/20> 1s 01.dat 18 newuser@csunix /2336/20> make lab20main 9 g++ -g -Wall-std-c++11lab20main.c -I/usr/local/2336/include -I 20 g++-o lab20main lab20main.o -L/usr/local/2336/1ib -1m-1bits 21 newuserQcsunix /2336/20 /1ab20main 22 Array a contains: 23 5 4 3 21 24 1 2 3 45 as Array b contains 26 7.7 6.6 5.5 4.4 3.3 2.2 1.1 2 1.1 2.2 3.3 4.4 5.5 6.6 7.7 28 Array c contains: 2 HEL L O 30 E HLL O 1Array d contains: 32 Cadillac Oldsmobile Chevrolet Toyota Lexus Dodge GMC BMw 3 BMW Cadillac Chevrolet Dodge GMC Lexus Oldsmobile Toyota s4 newuser csunix /2336/20> ./lab20main > my.out s newuser csunix /2336/20> diff 01.out my.out 3 newuser@csunix /2336/20> 01.out Makefile lab20.cpp b20main.c Figure 2. Commands to Compile, Link, & Run Lab 20
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started