Wednesday 16 April 2014

isalnum function in C


The C library function isalnum return non zero if character is alphanumeric (a-z, A-Z, 0-9) otherwise, it shall return 0.
Header File - #include<ctype.h>
Syntex - isalnum(variable name)


Isalnum() alphanumeric Example
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
       char numchar='A';
       if(isalnum(numchar))
       {
        printf("numchar = %c alphanumeric \n ",numchar);
       }
       else
       {
        printf("numchar = %c is not alphanumeric \n ",numchar);    
       }
       getch();
}

                         Output                                    





Isalnum() non alphanumeric Example
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
       char numchar='$';
       if(isalnum(numchar))
       {
        printf("numchar = %c alphanumeric \n ",numchar);
       }
       else
       {
        printf("numchar = %c is not alphanumeric \n ",numchar);    
       }
       getch();
}

                         Output                                    





Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...

0 comments:

Post a Comment