You are required to write a C++ program that creates a template function to find out...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 <iostream> and <algorithm > libraries. 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 <iostream> and <algorithm > libraries.
Expert Answer:
Answer rating: 100% (QA)
Heres a simple C program that fulfills your requirements include include template T maxNumberT arr i... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
A table of properties for methyl chloride lists the saturation pressure as 116.7 psia at 100oF. At 100oF, this table also lists hfg = 154.85 Btu/lbm, and vfg = 0.86332 ft3/lbm. Estimate the...
-
Sketch the graph of the function? 1. g(x) = [[x]] 2. g(x) = 4[[x]] 3. g(x) = [[x]] - 1 4. g(x) = [[x - 3]]
-
Micro Ltd, based in Perth, manufactures computers. Micro Ltds products are distributed through both independent and company-owned distribution entities, which are located throughout Australasia....
-
A ball is thrown vertically upward. (a) As it moves upward, it slows down under the influence of gravity. Considering the changes in energy of the ball, is the work done by Earth on the ball positive...
-
Varto Company has 7,000 units of its sole product in inventory that it produced last year at a cost of $22 each. This years model is superior to last years and the 7,000 units cannot be sold at last...
-
6. For an SHM oscillator, the amplitude is 5 cm and its time period is 4 seconds. The minimum time taken by the particle to pass between points which are at distances 4 cm and 3 cm from the centre of...
-
Blue Computers, a major server manufacturer in the United States, currently has plants in Kentucky and Pennsylvania. The Kentucky plant has a capacity of 1 million units a year, and the Pennsylvania...
-
How can financial advisors help their clients think biblically about taxes?
-
Discuss the use of different mediums in the gallery, such as paintings, sculptures, and mixed-media pieces. How did the choice of medium influence your interpretation of the artwork? Compare and...
-
Shawn is making a patio using 12 foot cement squares. The patio will be 12 cement squares wide by 12 cement squares long. If the cement squares are placed right next to each other without any espace...
-
How will knowledge about health care providers allow you to properly bill and code common gastrointestinal diseases? Provide details and support your responses with examples.
-
Making use of the basic concepts of portfolio theory and capital market theory to describe whether it is preferable to contain in a portfolio along with risky and risk-free (RF) securities. Graphic...
-
1. Discuss and describe the three-step portfolio management process with special emphasis on the investor's objectives and constraints. 2. Discuss how the concept of limits to arbitrage hinders...
-
The manager of AYEBANK records the arrival of customers and on average; three customers arrive per minute at the bank during the noon to 1 P.M. hour. What is the probability that at least two...
-
TRUE-FALSE QUESTIONS 1. In terms of preliminary analytical procedures, assume that the company has introduced a new product with a low price point and significant customer demand. The auditor would...
-
1. What ethical rules (see Chapter 3) should managers use to decide which employees to terminate when redesigning their hierarchy? 2. Some people argue that employees who have worked for an...
-
Think about the last time that you (1) were treated unfairly because you differed from a decision maker on a particular dimension of diversity or (2) observed someone else being treated unfairly...
-
Whom would you choose as a referent on this job? What steps would your manager take to make you feel that you were being equitably treated? What would you do if, after a year on the job, you...
-
With the availability of free credit reports, consumers are encouraged to check their report every 4 months-one report from each of the three major bureaus. In the past, consumers also were...
-
A leading financial publication reported that the average baby boomer credit user will pay approximately $1,200 in interest annually. If, instead of paying interest, this amount was saved every year,...
-
Some credit card issuers are beginning to assess fees and other charges on convenience users. Ask your friends and peers if they think a convenience credit card user should be charged for the...
Study smarter with the SolutionInn App