Saturday, March 6, 2021

, , , , ,

Example program for isxdigit() function in c

 The isxdigit() function in c programming checks whether a character is a hexadecimal digit character (0-9, a-f, A-F) or not.

Syntax for isxdigit in c :-

int isxdigit( int arg );

 isxdigit() Parameters

The isxdigit() in c takes a single character as it's parameter.

 C isxdigit() Return Value

 if passed argument is an hexadecimal character then isxdigit() return non-zero integer otherwise return 0.

Example program for C isxdigit() function


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

int main() {
   char c = '5';
   int result;

   // hexadecimal character is passed
   result = isxdigit(c); // result is non-zero
   printf("Result when %c is passed to isxdigit(): %d", c, isxdigit(c));

   c = 'M';

   // non-hexadecimal character is passed
   result = isxdigit(c); // result is 0

   printf("\nResult when %c is passed to isxdigit(): %d", c, isxdigit(c));

   return 0;
}

OUTPUT : - 



C isxdigit()
C isxdigit()

0 comments:

Post a Comment