C Program to Reverse the Case of Input Character using C Type library
ADVERTISEMENTS
C program to reverse the case of input character using c type library. In this article, you will learn how to make a c program to reverse the case of input character using c type library.
Example-1
'a' after conversion 'A'
Example-2
'A' after conversion 'a'
You should have knowledge of the following topics in c programming to understand this program:
- C Ctype library
- C
main()
function - C
if-else
condition statement - C
printf()
function
Source Code
// C Program to Reverse the Case of Input Character using C Type library
#include <stdio.h>
#include <ctype.h>
// ctype.h header file loaded to call the string functions
int main() {
char random_char;
printf("Enter an alphabet character to convert: ");
scanf("%c", &random_char);
printf("\nThe Reverse case of the '%c' is: '", random_char);
if (islower(random_char))
putchar(toupper(random_char));
else
putchar(tolower(random_char));
printf("'\n");
return 0;
}
Output
Enter an alphabet character to convert: a
The Reverse case of the 'a' is: 'A'
Explanation
In this given program, we have taken input a
from the user and applied the function to convert the input's reverse case.