TOGGLE CASE ID:235



Simon wishes to convert lower case alphabets to upper case and vice versa. Help Simon by writing a program which will accept a string value S as input and toggle the case of the alphabets.
Numbers and special characters remain unchanged.

Input Format:
First line will contain the string value S

Output Format:
First line will contain the string value with the case of the alphabets toggled.

Constraints:
Length of S is from 2 to 100

Sample Input/Output:

Example 1:
Input:
GooD mORniNg12_3

Output:
gOOd MorNInG12_3


Example 2:
Input:
R@1nBow

Output:
r@1NbOW


PROGRAM IN C:

#include <stdio.h>

#define MAX_SIZE 100 

void toggleCase(char * str);

int main()

{

    char str[MAX_SIZE];

scanf("%[^\n]s",str);


    toggleCase(str);


    printf("%s", str);


    return 0;

}

void toggleCase(char * str)

{

    int i = 0;


    while(str[i] != '\0')

    {

        if(str[i]>='a' && str[i]<='z')

        {

            str[i] = str[i] - 32;

        }

        else if(str[i]>='A' && str[i]<='Z')

        {

            str[i] = str[i] + 32;

        }


        i++;

    }

}

Comments

Popular Posts