comparesstring1to string2. It is a value returning function that returns a negative integer if string1 < string2, 0 if string1 == string2, and a positive integer if string1 > string2. Write a program that reads two names (last name first followed by a comma followed by the first name) and then prints them in alphabetical order. The two names should be stored in separate character arrays holding a maximum of 25 characters each. Use the strcmp() func- tion to make the comparison of the two names. Remember that 'a' < 'b', 'b' < 'c', etc. Be sure to include the proper header file to use strcmp().

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

Exercise2: Thestrcmp(string1,string2)function comparesstring1to string2. It is a value returning function that returns a negative integer if string1 < string2, 0 if string1 == string2, and a positive integer if string1 > string2. Write a program that reads two names (last name first followed by a comma followed by the first name) and then prints them in alphabetical order. The two names should be stored in separate character arrays holding a maximum of 25 characters each. Use the strcmp() func- tion to make the comparison of the two names. Remember that 'a' < 'b', 'b' < 'c', etc. Be sure to include the proper header file to use strcmp().

 
 

 

Sample Run 1:

Please input the first name

Brown, George

Please input the second name

Adams, Sally

The names are as follows:

Adams, Sally
Brown, George

 

 

Sample Run 2:

Please input the first name

Brown, George

Please input the second name

Brown, George

The names are as follows:

Brown, George
Brown, George
The names are the same

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Character class and its methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT