C Isdigit - C Standard Library
C Isdigit - C Standard Library
h/isdigit
C isdigit()
The isdigit() function checks whether a character is
numeric character (0-9) or not.
1 of 3 9/9/2022, 9:33 PM
Firefox https://www.programiz.com/c-programming/library-function/ctype.h/isdigit
#include <stdio.h>
#include <ctype.h>
int main()
{
char c;
c='5';
printf("Result when numeric character is passed: %d"
c='+';
printf("\nResult when non-numeric character is passed: %d"
return 0;
}
Output
#include <stdio.h>
#include <ctype.h>
int main()
{
char c;
if (isdigit(c) == 0)
printf("%c is not a digit.",c);
else
printf("%c is a digit.",c);
return 0;
}
Output
2 of 3 9/9/2022, 9:33 PM
Firefox https://www.programiz.com/c-programming/library-function/ctype.h/isdigit
Enter a character: 8
8 is a digit.
3 of 3 9/9/2022, 9:33 PM