C Program to Check Whether a Character is Alphabet or Not

  • Write a C program to check whether number is alphabet or not.
  • Write a program in C to find maximum node of binary tree.

Required Knowledge

C program to check whether a character is alphabet or not

C program to check whether a character is Alphabet or not

/*
 * C program to check whether a character is Alphabet or not 
 */ 
   
#include <stdio.h>  
   
int main() {  
    char character;
    /* 
     * Take a character as input from user 
     */
    printf("Enter a Character\n");  
    scanf("%c", &character);  
       
    if((character >= 'a' && character <= 'z')||(character >= 'A' && character <= 'Z')){
        printf("%c is an Alphabet\n", character);  
    } else {  
        printf("%c is Not an Alphabet\n", character);  
    }
   
    return 0;  
}

Output

Enter a Character
H
H is an Alphabet
Enter a Character
&
& is Not an Alphabet

C program to check whether a character is alphabet or not using isalpha function

C program to check whether a character is alphabet or not using isalpha function

/*
 * C program to check whether a character is Alphabet or not
 * using isalpha function 
 */ 
   
#include <stdio.h> 
#include <ctype.h> 
   
int main() {  
    char character;
    /* 
     * Take a character as input from user 
     */
    printf("Enter a Character\n");  
    scanf("%c", &character);  
       
    if(isalpha(character)) {  
        printf("%c is an Alphabet\n", character);  
    } else {  
        printf("%c is Not an Alphabet\n", character);  
    }
   
    return 0;  
}

Output

Enter a Character
g
g is an Alphabet
Enter a Character
+
+ is Not an Alphabet