This is a C program to print character in reverse case i.e. the program will read a character from keyboard and then print that character in lower case if it is in upper case or print in upper case if that input character is in lower case. This program will use c programming library functions like islower()
, isupper()
, toupper()
and tolower()
. All these functions are defined under header file <ctype.h>
.
#include <stdio.h>
#include <ctype.h>
main()
{
char x;
printf("Enter an alphabet :");
x = getchar(); // read a character from keyboard
if (islower(x))
putchar(toupper(x)); //change to uppercase
else
putchar(tolower(x)); //else change to lowercase
}
[adsense1]
OUTPUT
Enter an alphabet : d
D
Enter an alphabet : y
Y
In this program c programming functions like islower()
, isupper()
, toupper()
and tolower()
are used which are defined under header file called . That’s why it is included after standard header file
under which input output functions like
printf
and other are defined.