What is isdigit in c programming?
isdigit in c checks the passed character is decimal digit or not.
This function is defined in ctype.h header file.
This function returns non-zero digit if passed character is decimal value otherwise zero.
Prototype
int isdigit(int a);
Parmeter of isdigit in c
This function takes character as input parameter and converts it into ASCII value.
Return value of isdigit in c
This function returns non-zero value if passed character is digit otherwise zero.
Example program for isdigit function in c
#include<stdio.h>
#include<ctype.h>
int main()
{
int x='2';
int b='a';
printf("The passed value is %d \n",isdigit(x));
printf("The passed value is %d \n",isdigit(b));
return 0;
}
Code explanation
isdigit function is called to check whether the passed character is a decimal digit or not. The result is being printed onto the console.
Difference between isdigit and isalpha in c
isdigit function checks the passed character is a decimal digit or not. isalpha function checks the passed parameter is alphabet or not.
Prototypes are as follows
int isdigit(int a);
int isalpha(int a);
isdigit function in c | isalpha function in c |
Checks the passed character is decimal digit or not. | Checks the passed parameter is alphabet or not. |
int isdigit(int a); | int isalpha(int c); |
Difference between isdigit and isxdigit in c
isdigit function checks the passed character is a decimal digit or not. isxdigit function checks the passed character is hexadecimal or not.
Prototypes are as follows
int isdigit(int a);
int isxdigit(int a);
isdigit | isxdigit |
Checks the passed character is decimal digit or not. | Checks the passed character is hexadecimal or not. |
int isdigit(int a); | int isxdigit(int a); |
People also ask for
What is isdigit in c?
isdigit function checks the passed character is a decimal digit or not. It is defined in ctype.h header file.