C program to change case of a string

C program to convert all lower case letters of a string to upper case and vice versa.

#include <stdio.h>
#include<string.h>
int main()
{

char str[100];
int i=0;
printf("enter string ");
gets(str);

for(i=0; str[i]!='\0'; ++i){
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;}

}
for(i=0; str[i]!='\0'; ++i)
printf("%c",str[i]);

return 0;
}

 

Output