The C isxdigit function checks whether the given character is hexadecimal or not. The below isxdigit function accepts a character as the parameter and finds whether it is hexadecimal or not.
isxdigit(char)
isxdigit in C Programming Example
The isxdigit function finds whether the user-given character is hexadecimal or not.
#include <stdio.h> #include <ctype.h> int main() { char ch = '5'; if(isxdigit(ch)) { printf("\nYou have entered a Hexadecimal \n"); } else { printf("\n %c is not a Hexadecimal", ch); } return 0; }
You have entered a Hexadecimal
isxdigit Example 2
This program allows the user to enter any letter. Next, it checks whether the given character is hexadecimal or not using the C Programming function.
#include <stdio.h> #include <ctype.h> int main() { char ch; printf("Please Enter Any Valid Character: "); scanf("%c", &ch); if(isxdigit(ch)) { printf("\nYou have entered a Hexadecimal Character \n"); } else { printf("\n %c is not a Hexadecimal Character", ch); printf("\n I request you to enter a Hexadecimal Character \n"); } return 0; }
Let me enter another character.
Please Enter Any Valid Character: #
# is not a Hexadecimal Character
I request you to enter a Hexadecimal Character