isalpha in C Programming

The C isalpha is a Standard Library Function, which is useful to check whether the given character is an alphabet or not. The syntax of the C isalpha accepts a single character as the parameter and checks whether it is an alphabet or not.


isalpha in C Programming Example

The C isalpha method is useful for finding whether the given character is an alphabet or not. This program allows the user to enter any character. Next, it checks whether the given one is between A to Z or a to z using the isalpha function.

First, we declared a character variable called ch. The following C Programming printf statement will ask the user to enter. And then, we use the scanf to assign the user entered one to ch variable.

In this next line, we added the If Statement to check whether the character is between ‘A’ and ‘Z’ using the C isalpha function. If the condition is True, the printf statement inside the if block will print.

If the above If condition is FALSE, then the given character is not Alphabet. So, it will print the else block statements.

#include <stdio.h>
#include <ctype.h>

int main()
    char ch;
    printf("Please Enter Any Valid Character: \n");
    scanf("%c", &ch);

      printf("\n You have entered an Alphabet");         
      printf("\n %c is not an Alphabet", ch);
      printf("\n I request you to enter Valid Alphabet");	
isalpha in C Programming 1

Let me enter the Uppercase letter.

Please Enter Any Valid Character: 

 You have entered an Alphabet

The above C isalpha code will definitely check whether the given character is an alphabet or not, but what if we enter the numeric value? Please refer to C Program to check whether Alphabet or Not. It helps how to check whether the char is alphabet without using the isalpha function

Please Enter Any Valid Character: 

 9 is not an Alphabet
 I request you to enter Valid Alphabet

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.