C library function isdigit( )

In this tutorial, you will learn about C library function isdigit() which is a character handling function used to check whether the argument is a digit(0-9) or not. This function returns true(1) if the argument is digit else it returns 0.

We should include ctype.h header to use isdigit( ) function.

#include <ctype.h>

C library function isdigit( ): Function prototype

int isdigit( int ch);

This function checks whether its argument is a digit (0-9).

It returns a true value if the argument is a digit (0-9) and 0 otherwise.

Demonstration of isdigit( ):
4 is a digit
a is not a digit
$ is not a digit

Now, note the difference between conditional operator (?:) and if...else condition. Here, we have used if...else for selecting between two strings.

Related Articles:

C library function isalnum( ) In this tutorial, you will learn about C library function isalnum() which is a character handling function used to check whether...

C Library Function isxdigit( ) In this tutorial, you will learn about C library function isxdigit() which is a character handling function used to check whether the argument supplied is a hexadecimal character or...

C library function isalpha( ) In this tutorial, you will learn about C library function isalpha() which is a character handling function used to check whether the character is an alphabet...

C Library Function ispunct( ) In this tutorial, you will learn about C library function ispunct() which is a character handling function used to check whether the argument supplied is a printing character other...