Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

Program to test the character type

Posted By: Lauren Hughes     Category: C Programming     Views: 3492

Write a Program to test the character type.

Code for Program to test the character type in C Programming

   #include  <stdio.h>                                         
   #include  <ctype.h>                                         
   main()                                                      
   {                                                           
       char character;                                         
       printf("Press any key\n");                              
       character = getchar();                                  
       if (isalpha(character) > 0)                             
          printf("The character is a letter.");                
       elseif (isdigit (character) > 0)                         
             printf("The character is a digit.");              
          else                                                 
             printf("The character is not alphanumeric.");     
   }  
                                                         
Output                                                      
                                                               
   Press any key                                               
   h                                                           
   The character is a letter.                                  
                                                               
   Press any key                                               
   5                                                           
   The character is a digit.                                   
                                                               
   Press any key                                               
   *                                                           
   The character is not alphanumeric.                          
  
Share: 


Didn't find what you were looking for? Find more on Program to test the character type Or get search suggestion and latest updates.

Lauren Hughes
Lauren Hughes author of Program to test the character type is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!