(2) Create another cpp source file with name Name Sorting. Write a C++ program to read 5  words of your choice and store them by initializing an array of size 5 called word[]. Write  codes to sort these words into alphabetical order. Display the sorted words in a column.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question


(2) Create another cpp source file with name Name Sorting. Write a C++ program to read 5 
words of your choice and store them by initializing an array of size 5 called word[]. Write 
codes to sort these words into alphabetical order. Display the sorted words in a column.
Hints to Use: (1) For strings declared using char, data type, the likely functions to 
apply are strcpy(variable 1, variable2) for copying from variable2 to 
variable1, and strcmp(variable1, variable2) for comparison where results 
returned are -1, 0, 1 which are integers. The comparison tests done are
(variable1 == variable2) and (variable1 > variable2). If both variables are 
the same strings or same words, a 0 will be returned from the first 
comparison. If variable1 is alphabetically on the left and variable2 is on 
the right, -1 or a negative integer is returned from the second 
comparison. Otherwise, a 1 is returned, denoting that variable2 is greater 
than variable 1.
3
General syntax:
strcpy(variable1, variable2);
int cmp = strcmp(variable1, variable2);
(2) For strings declared using string data type, the likely procedures 
to apply are (variable 1 = variable2) for copying from variable2 to 
variable1, and (variable1 == variable2), (variable1 > variable2) and the 
else block all for comparison which results in a true or false. 
Besides the above, there is a comparison function called compare() which 
does the same thing as strcmp() of activity 2(1) above. This function 
returns a –ve, 0, +ve number. The general syntax of this function is
int cmp = declaredStringVariable.compare(variable1, variable); 

Expert Solution
Step 1

As per the given information, we need to read 5 words and sort them in alphabetical order. Then print the sorted words in column i.e line by line.

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY