Read into the computer a line of text containing both uppercase and lowercase letters. Printout the text with the uppercase and lowercase letters reversed, but all other characters intact.

Sample input:

I Love Programming.

Output:

i lOVE pROGRAMMING.

 Program:

/* c program to convert the upper case text to lower case text and vice versa    */
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main()
{
       char line[80];
       printf("enter some text: ");
       scanf(" %[^\n]",line);
       int len= strlen(line);
       int I;
       for(i=0;i<len;i++)
       {
                if(line[i]>='a' && line[i]<='z')
                        line[i]=toupper(line[i]);
                else if(line[i]>='A' && line[i]<='Z')
                        line[i]=tolower(line[i]);
        }
        printf("%s",line);
        return 0;
}

Note: Here the tests for lowercase and uppercase are not necessary. Think and comment if you need any help

No comments: