Question: Write a C program to read strings from the user until the program reads the END string. For each string, use the C program to

Write a C program to read strings from the user until the program reads the END string. For each string, use the C program to change the lowercase letters (a to z) to upper case letters (A to Z) and change the uppercase letters to lowercase letters. The program should output the changed strings to the screen.

Hint: (i) You can use fgets() to read a string. After read the string, you can use strcmp(str, END ) to judge whether the input string is END, where is the new line character read by the fgets() function. (ii) For a lowercase character ch, use ch - 32 to get its uppercase letter. For a uppercase letter ch, use ch + 32 to get its lowercase letter. (iii) You can assume that the maximum length of the input string is 1024. (iv) You can use a for loop from 0 to strlen(string) to iterate all the characters in the string. (v) For a character ch, you can use a <= ch && ch <= z to judge whether ch is a lowercase letter. The condition to judge a uppercase letter is similar.

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 Databases Questions!