Toggle String

You have been given a String S consisting of uppercase and lowercase English alphabets. You need to change the case of each alphabet in this String. That is, all the uppercase letters should be converted to lowercase and all the lowercase letters should be converted to uppercase. You need to then print the resultant String to output.

Input Format
The first and only line of input contains the String S

Output Format
Print the resultant String on a single line.

Constraints
C++

#include <bits/stdc++.h>
using namespace std;
int main(){
    const int selisih=(int)'a'-(int)'A';
    char a;
    while(cin>>a){
	    if((int)a<97){
	         cout<<(char)(a+selisih);
	    }else{
	       cout<<(char)(a-selisih);
	    }
    }
    //cout<<(int)'a'+<<endl;
    return 0;
}
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

You cannot copy content of this page

0
Would love your thoughts, please comment.x
()
x