Menu Close

Convert all Uppercase letters to Lowercase and vice-versa

Lokesh have been given a String S consisting of uppercase and lowercase English alphabets. Lokesh 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. 

Lokesh need to then print the resultant String to output. But Lokesh is finding it difficult to implement it.

Can you help Lokesh complete his task?

Input:
input contains the String S

Output:
Print the String
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
    int i;
    char ch[100];
    scanf("%s",ch);
    for(i=0;i<strlen(ch);i++)
    {
        if(isupper(ch[i]))
        ch[i]=tolower(ch[i]);
        else
        ch[i]=toupper(ch[i]);

    }
    printf("%s",ch);

	return 0;
}

INPUT_1:
maHenDraSinghDhOni

OUTPUT:
MAhENdRAsINGHdHoNI


INPUT_2:
uMeshYaDhaV

OUTPUT:
UmESHyAdHAv


ILLUSTRATION

Executed using gcc

Morae Q!