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
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