In this tutorial, you will learn about C library function `isxdigit()` which is a character handling function used to check whether the argument supplied is a hexadecimal character or not.

As discussed earlier, we have to include `ctype.h` header file for using `isxdigit( )` standard character library function.

`#include <ctype.h>`

## C library function isxdigit( ): Function prototype

``int isxdigit( int ch);``

This function checks whether its argument is a hexadecimal digit character or not. Hexadecimal means `A - F , a - f, 0 - 9`.

It returns a true value if `ch` is a hexadecimal digit character and zero (0) otherwise.

### Example: Demonstration of isxdigit( ) function

``````#include <stdio.h>
#include <ctype.h>

int main()
{
printf("Demonstration of isxdigit():\n");
printf("\n%s%s", isxdigit('D') ? "D is a " : "D is not a ", "hexadecimal digit");
printf("\n%s%s", isxdigit('H') ? "H is a " : "H is not a ", "hexadecimal digit");
printf("\n%s%s", isxdigit('e') ? "e is a " : "e is not a ", "hexadecimal digit");
printf("\n%s%s", isxdigit('6') ? "6 is a " : "6 is not a ", "hexadecimal digit");
printf("\n%s%s", isxdigit('!') ? "! is a " : "! is not a ", "hexadecimal digit");

return 0;
}
``````

Output

```Demonstration of isxdigit():

H is not a hexadecimal digit
! is not a hexadecimal digit```

Explanation
In the above example, standard character library function `isxdigit` determines whether its argument is a hexadecimal digit or not.

Conditional operator `?:` does the selection between two strings `"is a"` and `"is not a"`.

This can be simply done with the help of `if...else` statements.

``````#include <stdio.h>
#include <ctype.h>

int main()
{
printf("Demonstration of isxdigit( ):\n");

if( isxdigit('D') == 0)
else

if( isxdigit('H') == 0)
else

if( isxdigit('e') == 0)
else

if( isxdigit('6') == 0)
else

if( isxdigit('!') == 0)
else

return 0;
}
``````

Output

```Demonstration of isxdigit():

H is not a hexadecimal digit
! is not a hexadecimal digit```

Explanation
In this example, we have used `if...else` statements instead of a conditional operator.

Here, `if...else` statement does the selection between two strings.