isalpha() - Character Function

How is "isalpha()" used in C++?


isalpha() function is used to check whether the given argument is an alphabet. It returns zero when the argument does not have any of them.


int isalpha ( int c );

Example :

#include <iostream.h>
#include <ctype.h>
int main()
char a;
cout<<"Enter a Alphabet: ";
cin >>a;
cout << "Good entered a alphabet\n";
cout << "Not an alphabet\n";
return 0;

Result :

Enter a Alphabet : e
Good entered a alphabet

In the above example, this function is used to check if the entered character is in the range "a-z" or "A-Z". Based on the ASCII value , it will check if it is an alphabetic character or not.

C++ Tutorial

Ask Questions

Ask Question