Question: You are required to write a C++ program that creates a template function to find out the maximum value in arrays. Your program is

You are required to write a C++ program that creates a template function to find out the maximum value in

You are required to write a C++ program that creates a template function to find out the maximum value in arrays. Your program is required to create three arrays of different data types, e.g., double, int and string. You are free to create different size arrays, e.g., 4 elements in double, 6 elements in int and 5 elements in string array. You are also free to hardcode the values of these arrays. For sample values, see the expected output of the program. Once arrays are created, use lambda functions to display all the elements of these arrays. Your program should have a T max_numbers (T arr[], int size) function which takes an array and size of the array from the main method and finds the maximum value in these arrays and returns it. Make sure your function works for above mentioned 3 data types. If you provide double or int array to the function, it should return the max. element in their respective arrays. If, however, you provide a string array to the function, the function should return the element of the array which is the largest (has max. number of characters) amongst the string array. Please refer to the expected output screenshot below for more information. You are free to code this whole program in the main method if you like except the max_numbers function, which you have to create separately. You are most welcome to create separate functions if you consider them necessary. You can only use and libraries.

Step by Step Solution

3.39 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a simple C program that fulfills your requirements include include template T maxNumberT arr i... View full answer

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 Programming Questions!