For all of these programs, never use using namespace std;
. Declare each function explicitly as necessary.
-
Write a function named
insertionSort
that takes a pointer to an integer and an integer as arguments. The function should sort the array passed to it using the insertion sort algorithm and print out each step of the process. Demonstrate the function in a program. Do the same for selection sort, or any other sorting algorithm that interests you. -
Write a function template named
sum
that takes two different types as arguments. The function returns the sum of the two values passed to it, using the type given by the first value. Demonstrate the template in a program with combinations ofint
anddouble
. -
Write two functions that each take a pointer to an integer, an integer, and a string as arguments. One function,
arrayToFile
, should push the contents of the given array to the given filename. The other function,fileToArray
, pushes the contents of the file to the array. Demo