Question
In C++ Language In this question you have to use character arrays to do the following: you need to allow the user to enter three
In C++ Language In this question you have to use character arrays to do the following: you need to allow the user to enter three different names (which may include whitespaces). You will store each of these names in different character arrays (you can keep their size at 100 each). You will then call a function with the following prototype:
void orderNamesByLength(char name1[], char name2[], char name3[]);
This function will do the following: it will take as input all of the 3 character arrays storing the three different names, and it will sort them on the basis of the length of the names, so that finally the first character array should store the shortest name, the second character array should store the second shortest name, and the last character array should store the longest name. The function orderNamesByLength should only do the work of rearranging or swapping the character arrays according to length, printing out all of the character arrays after this function is called should be done in the main function.
An example of a possible set of input values and desired output is shown here:
Note: Keep in mind, you do not need to use any loops within the function. Some if conditions would be enough.
Hint: You will benefit from the use of some temporary character arrays within the function for swapping. You can use functions such as strlen and strcpy from the library to help you out.
Mustansar Hussain Tarar Shaheen Afridi Hassan Ali After sorting the names based on length (ascending order): Hassan Ali Shaheen Afridi Mustansar Hussain TararStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started