Q:

C Program to toggle case of all characters of string

0

C Program to toggle case of all characters of string

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<stdio.h>
 
int main()
{
    char text[100];
    int i;
     
    printf("Enter any string: ");
    gets(text);
     
    printf("Entered string is: %s\n",text);
     
   
    for(i=0;text[i]!='\0';i++)
    {
        
        if((text[i]>='A' && text[i]<='Z')||(text[i]>='a' && text[i]<='z'))
        {
            
            if(text[i]>='A' && text[i]<='Z')
                text[i]=text[i]+0x20;
            else
                text[i]=text[i]-0x20;
        }
    }
     
    printf("String after toggle case: %s\n",text);
 
    return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now