C - Write program to change letter case in a string

Requirements

Write a program that changes all the uppercase letters in a string of text to lowercase and changes the lowercase letters to uppercase.

Display the results.

Hint

Use ctype function

Demo

#include <stdio.h>
#include <ctype.h>

int main()/*from   w  w  w . ja  v  a 2s.  c  om*/
{
    char text[] = "ThiS Is a RANsom NoTE!";
    int index;
    char c;

    printf("Original: %s\n",text);
    index=0;
    while(text[index])
    {
        c = text[index];
        if(islower(c))
            text[index] = toupper(c);
        else if(isupper(c))
            text[index] = tolower(c);
        else
            text[index] = c;
        index++;
    }
    printf("Modified: %s\n",text);
    return(0);
}

Result