This C program converts lowercase alphabet to uppercase and uppercase alphabet to lowercase by using if-else statements.
ASCII value of uppercase alphabets ranges from 65-90, and ASCII value of lowercase alphabets ranges from 97-122.
Program:
#include<stdio.h> void main() { char ch; int n; printf("Enter an alphabet:"); scanf("%c",&ch); n=ch; if(n>=65&&n<=90) /*if the entered alphabet is in uppercase*/ { n+=32; printf("\n %c \n",n); } else if(n>=97&&n<=122) /*if the entered alphabet is in lowercase*/ { n-=32; printf("\n %c \n",n); } else printf("\n Wrong choice!!! \n"); }
OUTPUT:
Enter an alphabet:
F
Enter an alphabet:P
p
Enter an alphabet:4
Wrong choice!!!
Happy coding!!!