# isxdigit() function in C Language

isxdigit() function in C programming language checkes that whether the given character is hexadecimal or not. isxdigit() function is defined in ctype.h header file.

```Hexadecimal: 0   1   2   3    4   5    6   7    8   9    A    B       C      D    E     F
Decimal:    0   1    2   3    4   5    6   7    8   9    10   11    12     13    14    15
```

Syntax:

```char isxdigit( char x);
```

Examples:

```Input : A
Output : Entered character is hexadecimal
Input : 2
Output : Entered character is hexadecimal
Input : @
Output : Entered character is not hexadecimal
```

 `// C program to demonstrate isxdigit() ` `#include ` `#include ` ` `  `int` `main() ` `{ ` `    ``// taking input ` `    ``char` `ch = ``'A'``; ` ` `  `    ``// checking is the given input is hexadecimal or not? ` `    ``if` `(``isxdigit``(ch)) ` `        ``printf``(``"\nEntered character is hexadecimal"``); ` `    ``else` `        ``printf``(``"\nEntered character is not hexadecimal"``); ` `} `

Output:

```Entered character is hexadecimal
```

Application : isxdigit() function in C programming language is used to find out total numbers of hexadecimals present in any given input.
Example:

```Input: abc123
Output: Number of hexadecimals present in the given input is : 6
Input: abcdef
Output: Number of hexadecimals present in the given input is : 6
Input: 123456@\$
Output: Number of hexadecimals present in the given input is : 6
```

Let’s see C program on this topic:

 `// C program to demonstrate isxdigit() ` `#include ` `#include ` ` `  `int` `ttl_hexadecimal(``int` `i, ``int` `counter) ` `{ ` `    ``char` `ch; ` `    ``char` `a[50] = ``"@#asf12345"``; ` `    ``ch = a[0]; ` ` `  `    ``// counting of hexadecimal numbers ` `    ``while` `(ch != ``'\0'``) { ` `        ``ch = a[i]; ` `        ``if` `(``isxdigit``(ch)) ` `            ``counter++; ` ` `  `        ``i++; ` `    ``} ` ` `  `    ``// returning total number of hexadecimal ` `    ``// in the given input ` `    ``return` `(counter); ` `} ` ` `  `int` `main() ` `{ ` `    ``int` `i = 0; ` `    ``int` `counter = 0; ` `    ``counter = ttl_hexadecimal(i, counter); ` ` `  `    ``printf``(``"\nNumber of hexadecimals in string"` `             ``" is : %d"``, counter); ` `    ``return` `0; ` `} `

Output:

`Number of hexadecimals in string is : 7`

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.