
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
isalpha and isdigit in C/C++
isalpha()
The function isalpha() is used to check that a character is an alphabet or not. This function is declared in ctype.h header file. It returns an integer value, if the argument is an alphabet otherwise, it returns zero.
Here is the syntax of isalpha() in C language,
int isalpha(int value);
Here,
value ? This is a single argument of integer type.
Here is an example of isalpha() in C language ?
Example
#include<stdio.h> #include<ctype.h> int main() { char val1 = 's'; char val2 = '8'; if(isalpha(val1)) printf("The character is an alphabet\n"); else printf("The character is not an alphabet\n"); if(isalpha(val2)) printf("The character is an alphabet\n"); else printf("The character is not an alphabet"); return 0; }
Output
Here is the output
The character is an alphabet The character is not an alphabet
isdigit()
The function isdigit() is used to check that character is a numeric character or not. This function is declared in "ctype.h" header file. It returns an integer value, if the argument is a digit otherwise, it returns zero.
Here is the syntax of isdigit() in C language,
int isdigit(int value);
Here,
value ? This is a single argument of integer type.
Here is an example of isdigit() in C language,
Example
#include<stdio.h> #include<ctype.h> int main() { char val1 = 's'; char val2 = '8'; if(isdigit(val1)) printf("The character is a digit\n"); else printf("The character is not a digit\n"); if(isdigit(val2)) printf("The character is a digit\n"); else printf("The character is not a digit"); return 0; }
Output
Here is the output
The character is not a digit The character is a digit