In this tutorial learn how you can write a c program to read a character from keyboard and convert it to uppercase if it is lower case and vice versa. 

We are going to use a ctype library. That we use <ctype.h> header file. Then we use some function like:

isupper();

tolower();

toupper();

C programming is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, etc.

write c program to convert uppercase to lowercase and vice versa


Write a Program to Convert Uppercase to Lowercase and Vice Versa

Here is the code to read a character from keyboard and convert it to uppercase if it is lower case and vice versa in C programming.

#include <stdio.h> //WAP to read a character from keyboard. Convert it to uppercase if it is lower case and vice versa
#include <ctype.h>
int main(){
char word;
printf("Please enter any character:");
scanf("%c",&word);
if(isupper(word)==1){
printf("Converted Character is %c.",tolower(word));

}else {printf("Converted Character is %c.",toupper(word));}
return 0;
}

Test Live At Jdoodle


Conclusion

This is how you can read a character from keyboard and convert it to uppercase if it is lower case and vice versa in c programming. Comment below if you like our tutorial.