Here, our task is to replace all the lower-case characters in the string to upper-case and upper-case characters to lower-case. For this purpose, we need to traverse the string and check for each character. If the character is a lower-case character, make it upper-case by using the language-specific built-in method or add 32 to the lower-case character in C to change the ASCII value of the character.
Algorithm
- Define a string and traverse through it.
- If the lower-case character is encountered then convert them in upper case character using built-in function.
- If the upper-case character is encountered then convert them in upper case character using built-in function.
- If it's a character other than upper-case or lower-case alphabet take the character as it is.
Input:
str1 = "Great Power"
Output:
String after case conversion : gREAT pOWER
Python
Output:
C
Output:
JAVA
Output:
C#
Output:
PHP
Output: