An error (probably a typo):
else if (ch>='a' && ch<='a')
This should have been:
else if (ch>='a' && ch<='z')
Secondly, to call the function in main, something like this should suffice:
char ch;
ch=uppertolowertoupper('c');
printf("%c",ch);
The above works only if you have declared or defined the function before main
.
Declared before main:
char uppertolowertoupper(char);
int main()
{
char ch;
ch=uppertolowertoupper('c');
printf("%c",ch);
}
char uppertolowertoupper(char ch)
{
// your function
}
Defined before main:
char uppertolowertoupper(char ch)
{
if (ch>='A' && ch<='Z')
{
ch=tolower(ch);
return ch;
}
else if (ch>='a' && ch<='z')
{
ch=toupper(ch);
return ch;
}
}
int main(){
char ch;
ch=uppertolowertoupper('c');
printf("%c",ch);
return 0;
}