4. Answer each of the following programming questions (using C++)__(2+2+6) a) Declare a function called Longest...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
4. Answer each of the following programming questions (using C++)__(2+2+6) a) Declare a function called Longest that takes an array X (of type string) and number of data N as input and that returns the longest string (output type is a string). b) Given a function declaration as below: void Mystery(char X[ ], int m, int n); Where m is the starting index and n represent total number of data in the array. Given a character array as below: char vowels[ ] = {‘a’, ‘e', 'I’, ‘o’, ‘u’}; How will you call the function Mystery for the array vowels? Write down the function call only. c) Given the pseudocode for Binary search algorithm as below: Assume A is an array of integer type. The variables m, n and P are all of type integers. BinarySearch ( A, m, n, P) if m <= n mid ← (m +n)/2 if A[mid] = P return mid else if P < A[mid] else return BinarySearch(A, m, mid-1, P) else return BinarySearch(A, mid+1, n, P) return -1 // close of function Write this function properly in C++ 4. Answer each of the following programming questions (using C++)__(2+2+6) a) Declare a function called Longest that takes an array X (of type string) and number of data N as input and that returns the longest string (output type is a string). b) Given a function declaration as below: void Mystery(char X[ ], int m, int n); Where m is the starting index and n represent total number of data in the array. Given a character array as below: char vowels[ ] = {‘a’, ‘e', 'I’, ‘o’, ‘u’}; How will you call the function Mystery for the array vowels? Write down the function call only. c) Given the pseudocode for Binary search algorithm as below: Assume A is an array of integer type. The variables m, n and P are all of type integers. BinarySearch ( A, m, n, P) if m <= n mid ← (m +n)/2 if A[mid] = P return mid else if P < A[mid] else return BinarySearch(A, m, mid-1, P) else return BinarySearch(A, mid+1, n, P) return -1 // close of function Write this function properly in C++
Expert Answer:
Answer rating: 100% (QA)
For question 4a youre asked to declare a function called Longest which takes an array of strings and ... View the full answer
Related Book For
Concepts of Database Management
ISBN: 978-1285427102
8th edition
Authors: Philip J. Pratt, Mary Z. Last
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
KYC's stock price can go up by 15 percent every year, or down by 10 percent. Both outcomes are equally likely. The risk free rate is 5 percent, and the current stock price of KYC is 100. (a) Price a...
-
If the resultant force acting on the hook is F R = {? 200i + 800j + 150k} lb, determine the magnitude and coordinate direction angles of F. 30 F= 600 ib
-
Why are documents and records a feature of internal control systems?
-
Define the terms fixed cost and variable cost. Explain how an understanding of the distinction between fixed cost and variable cost can be useful to managers.
-
How can an auditor test the authenticity of employees to whom payroll checks are disbursed?
-
Barbara Bright is the purchasing agent for West Valve Company. West Valve sells industrial valves and fluid control devices. One of the most popular valves is the Western, which has an annual demand...
-
Make an ERD diagram to display the relationships between VETERINARYOFFICE ( petName, petType, petBreed, petDOB, ownerName, ownerPhone, ownerEmail, serviceDescription, serviceDate, amountBilled) ?
-
The Harvard Co-op orders sweatshirts with the Harvard University emblem on them and sells them for $50 each. During a typical month, 900 sweatshirts are sold (this includes all styles and sizes...
-
Rising natural gas prices during the turn of the current century coupled with technological advances spurred interest in the Marcellus shale in northeastern Pennsylvania. Although the thickness of...
-
In the figure below, find each of the following.(a) the length of the side opposite (b) the length of the side adjacent to p (C) cos(8) (d) sin(p) (e) tan(p)
-
The atomic weight of aluminum (Al) is based on its only naturally occurring isotope, which has an atomic mass of 26.98153860000 u. (a) Write the complete atomic symbol for aluminum . How many...
-
Spacetime intervals reveal length contraction Planet X is 60 lightyears away from Earth. Assume that there is no relative motion between Planet X and Earth (i.e., from the Earth, it appears that...
-
Build a star system You decide that you want to build a stellar system that consists of four suns each of mass 2.0\times 10^30kg placed in a configuration so that each star is at the corner of a box...
-
How long would the Earth's day ( 2 4 h ) last if the Earth swirled at such a speed that the bodies on the equator would weigh half as much less than at the pole?
-
Problem 13-4A (Algo) Calculating financial statement ratios LO P3 Selected current year-end financial statements of Cabot Corporation follow. (All sales were on credit: selected balance sheet amounts...
-
This problem continues the Draper Consulting, Inc., situation from Problem 12-45 of Chapter 12. In October, Draper has the following transactions related to its common shares: Oct 1 Draper...
-
Give an example of a column A and a column B such that B is functionally dependent on A. Give an example of a column C and a column D such that D is not functionally dependent on C.
-
For the following exercises, you will address problems and answer questions from management at TAL Distributors. You do not use the TAL Distributors database for any of these exercises. 1. While...
-
What is the system catalog? Name three items about which the catalog maintains information.
-
A4-stroke, 4-cylinder, single acting spark ignition petrol engine develops \(20 \mathrm{~kW}\) brake power at \(3000 \mathrm{rpm}\). The following data are given : Bore \(=65 \mathrm{~mm}\), Stroke...
-
The following data is available for an engine working on ideal Otto cycle Temperature at the beginning of compression \(=50^{\circ} \mathrm{C}\). Temperature at the end of compressor \(=373^{\circ}...
-
A six cylinder four stroke I.C. Engine is to develop \(100 \mathrm{~kW}\) i.p. at 800 RPM. The stroke to bare ratio is 1.25. Assuming Mechanical efficiency of \(80 \%\) and break mean effective...
Study smarter with the SolutionInn App