- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
isalnum() function in C Language
The function isalnum() is used to check that the character is alphanumeric or not. It returns non-zero value, if the character is alphanumeric means letter or number otherwise, returns zero. It is declared in “ctype.h” header file.
Here is the syntax of isalnum() in C language,
int isalnum(int character);
Here,
character − The character which is to be checked.
Here is an example of isalnum() in C language,
Example
#include<stdio.h> #include<ctype.h> int main() { char val1 = 's'; char val2 = '8'; char val3 = '$'; if(isalnum(val1)) printf("The character is alphanumeric
"); else printf("The character is not alphanumeric
"); if(isalnum(val2)) printf("The character is alphanumeric
"); else printf("The character is not alphanumeric"); if(isalnum(val3)) printf("The character is alphanumeric
"); else printf("The character is not alphanumeric"); return 0; }
Output
The character is alphanumeric The character is alphanumeric The character is not alphanumeric
In the above program, three variables of char type are declared and initialized with the values. These variables are checked that these values are alphanumeric or not by using isalnum() function.
if(isalnum(val1)) printf("The character is alphanumeric
"); else printf("The character is not alphanumeric
");
Advertisements