Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Code Get Longest String Ask the user to input five strings and store them into an array. Then use the get_longest_string function to find

C++ Code

Get Longest String

Ask the user to input five strings and store them into an array. Then use the get_longest_string function to find the longest string in that array and return it.

get_longest_string should have two parameters.

  1. The array that contains all the strings.
  2. The size of the array.

Sample output

Please enter string #1: Hey Please enter string #2: hey Please enter string #3: whats Please enter string #4: up Please enter string #5: people The longest string is: people

In the case of two strings having the same length, then you should return the first of the two strings of the same length. For example:

Please enter string #1: Hello Please enter string #2: fee Please enter string #3: fi Please enter string #4: fo Please enter string #5: World The longest string is: Hello

Important note

Please make sure to create the get_longest_string function prototype in get_longest_string.hpp and its implementation in get_longest_string.cpp.

The main function in main.cpp already contains most of the implementation for retrieving input from the user. However, you need to properly create and store the inputs into an array and call the get_longest_string function appropriately.

Hint

std::string is a class which means it has data members and member functions. Try to see if you can find the right member function to help you out. This website provides the std::string class' member function list with their corresponding descriptions.

Step by Step Solution

3.33 Rating (153 Votes )

There are 3 Steps involved in it

Step: 1

Code include include Solutionh ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Matlab An Introduction with Applications

Authors: Amos Gilat

5th edition

1118629868, 978-1118801802, 1118801806, 978-1118629864

More Books

Students also viewed these Programming questions

Question

Solve the following 1,4 3 2TT 5x- 1+ (15 x) dx 5X

Answered: 1 week ago