Table of Content

isalpha function > ctype.h > header files in c Programming



isalpha function > ctype.h > header files in c Programming

Syntax int isalpha (int c)
Header File ctype.h
Return Value
  • Return non-zero if character is either alphabet
  • Return zero if character is not alphabet

Live Example :


void main()
{
char ch = '1';

if(isalpha(ch))

printf("nThis is alphabet character");

else

printf("nThis is non alphabet character");
}



Output : 
This is not alphabet character

Following are alphabet characters :
  1. Uppercase Letters [ A-Z]
  2. Lowercase Letters [a-z]
Explanation of statement : if(isalpha(ch))
  1. character ch is passed to function isalpha
  2. if ch belongs to the set of alphabet character then it returns positive value 
  3. otherwise it returns zero .
Note : 
  1. Positive non-zero value given to if block , will result in TRUE condition
  2. Zero value given to if block , will result in FALSE condition

Question How we are passing character value to function , which contradicts to the Given Syntax ?
Answer
We are passing character to function , automatically gets converted into (int) equivalent ascii value  


    Bookmark & Share