isalpha() - Character Function
How is "isalpha()" used in C++?
Explanation
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.
Syntax:
int isalpha ( int c );
Example :
#include <iostream.h> #include <ctype.h> int main() { char a; cout<<"Enter a Alphabet: "; cin >>a; if(isalpha(a)) { cout << "Good entered a alphabet\n"; } else { 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.