Before writing program for lowercase to uppercase and vice versa conversion, we should know ascii value corresponding lowercase and uppercase alphabets.
A – Z = 65 – 90
a – z = 97 – 122
Try below program:
#include<stdio.h>
int main()
{
char ch , chr;
scanf(“%c”,&ch);
chr = ((ch >= ‘A’ && ch <= ‘Z’) ? (ch + ‘a’ – ‘A’) : (ch + ‘A’ – ‘a’));
printf(“%c”,chr);
}
Output:
$ ./a.exe
Z
z
$ ./a.exe
d
D