Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

warning: do not use vector to complete this exercise! Write a program that will take N words (separated by white spaces) as input and return

image text in transcribed

warning: do not use vector to complete this exercise! Write a program that will take N words (separated by white spaces) as input and return the word that has the most letters. You can safely assume that N is always less than or equal to 10 , and the word that has the most letters is unique. The input starts with an integer indicating the number of words that the user will enter next. You need to use a string array to store these N words. You must define a function that takes this string array and the number of words in the array as input and returns the word that has the most letters and its location (i.e. index) in the array. You function should have the following signature string findLongestWord(string words[ ], int nWords, int \&position); For example, if the user enters the following 5 welcome to the cosc1437 course and the program will output CosC1437 has the most letters and its index in the array is 3 Another example, if the user enters 6 This winter is very very cold the program will output winter has the most letters and its index in the array is 1 Hint: use the length() function to count the number of characters in a string. Any attempt to hard code the output will result in 0 for this exercise

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Mysql Examples Explanations Explain Examples

Authors: Harry Baker ,Ray Yao

1st Edition

B0CQK9RN2J, 979-8872176237

More Books

Students also viewed these Databases questions