Home » C programs » ctype.h header file functions

isxdigit() function of ctype.h in C



In this article, we are going to learn about the isxdigit() function of ctype.h header file in C programming language and use it with the help of an example.
Submitted by Abhishek Sharma, on April 11, 2018

This function is used to check if the character is hexadecimal or not, the Function returns 1 if the character is hexadecimal and 0 if the character is not hexadecimal.

The Hexadecimal characters are typically in the range of,

  1. 0 - 9
  2. A - F
  3. a - f

Anything else other than this is not hexadecimal.

Example:

    Input character is: 'a'
    Function will return 1


    Input character is: 'Z'
    Function will return 0


ctype.h - isxdigit() function Example in C

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

int main()
{
    // defining the type of variable
    char a,b,c;

    // assigning the values of variables
    a = '5';
    b = 'c';
    c = 'z';


    // Condition to check, if the value of variable is hexadecimal digit
    if (isxdigit(a))
    {
     printf("%c is hexadecimal\n", a);
    }
    else
    {
     printf("%c is not hexadecimal\n", a);
    }

    // Condition to check, if the value of variable is hexadecimal digit
    if (isxdigit(b))
    {
     printf("%c is hexadecimal\n", b);
    }
    else
    {
     printf("%c is not hexadecimal\n", b);
    }

    // Condition to check, if the value of variable is hexadecimal digit
    if (isxdigit(c))
    {
     printf("%c is hexadecimal\n", c);
    }
    else
    {
     printf("%c is not hexadecimal\n", c);
    }

    return 0;
 }

Output

ctype.h - isxdigit()  in c language






Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.




Comments and Discussions





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.




close Like other websites, this site uses cookies to deliver relevant ads based on your interest, by using our website, you acknowledge that you have read our privacy policy.