Showing posts with label C isdigit(). Show all posts
Showing posts with label C isdigit(). Show all posts

Thursday, February 25, 2021

, , , ,

Example Program for isdigit() in c - Function in c

 isdigit() function in C programming use to checks whether a character is numeric character (0-9) or not.

 Prototype of isdigit() Function in C

int isdigit( int arg );


  • isdigit() function in c programming take a single argument which is an integer and return type int.
  • Given character is converted to its ASCII value in isdigit() Function
  • It is defined in <ctype.h> header file in c.

Return value for C isdigit()

isdigit() Return value in c
 isdigit() Return value in c


Example Program for isdigit() function in c


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

int main()
{
    char c;
    c='5';
    printf("Result when numeric character is passed: %d", isdigit(c));

    c='+';
    printf("\nResult when non-numeric character is passed: %d", isdigit(c));

    return 0;
}

OUTPUT : - 

Result when numeric character is passed: 1
Result when non-numeric character is passed: 0