Question: 3 . 3 0 LAB: Working with Strings Write a program in C programming to display which string has more characters, which string comes first

3.30 LAB: Working with Strings
Write a program in C programming to display which string has more characters, which string comes first alphabetically, and to replace the last character in a
string with an uppercased letter. The program will ask the user for two strings (size the string for 20 characters) and then display the
required information.
(1) Ask the user for a string. (1 pt.)
Enter the first string:
George
(2) Ask the user for a second string. (1 pt)
Enter the first string:
George
Enter the second string:
Billy
(3) Display which string has more characters. (1 pt)
Hint: You will need the strlen()(STRing LENgth) function, which is part of the string.h library.
Enter the first string:
George
Enter the second string:
Billy (4) If the two string have the same number of characters, display that they are equal lengths. (1 pt)
Enter the first string:
Scott
Enter the second string:
Billy
The 2 strings, Scott and Billy, are equal lengths.
(5) Display which string comes first alphabetically. (3 pts)
Hint: You will need the strcmp()(STRing CoMPare) function.
Enter the first string:
George
Enter the second string:
Billy
George is the longer string.
The string that comes first alphabetically is Billy. (6) Convert the last character in the first string to uppercase. (3 pts)
Hint: Get the last character in the string, convert it to uppercase (you will need the toupper() function, which is part of the ctype.h
library), and then assign it to the last character position of the string
Enter the first string:
George
Enter the second string:
Billy
George is the longer string.
The string that comes first alphabetically is Billy.
George with the last character converted to uppercase is GeorgE.
LAB
3.30.1: LAB: Working with Strings
main.c
Load default template...
#include
3 . 3 0 LAB: Working with Strings Write a program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!