C isalpha() library function

isalpha() function checks whether a character is an alphabet or not. Alphabet characters include lowercase letters(a-z) and uppercase letters(A-Z).

Function prototype of isalpha

int isalpha(int c);
Function isalpha takes a character as input in form of an integer. When we pass a value of type char to isalpha function, corresponding ASCII value of that character is passed.

Return value of isalpha

If passed character is an alphabet, then isalpha function returns non-zero integer otherwise 0.

C program to show the use of isalpha function

The following program is to check whether a character is alphabet or not.

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

int main(){
    char string[] = "Aa1@; .0";
    int index = 0;
    
    while(string[index] != '\0'){
        if(isalpha(string[index])){
            printf("'%c' is alphabet\n", string[index]);
        } else {
            printf("'%c' is not alphabet\n", string[index]);
        }
        index++;
    }
    
    return 0;
}

Program Output
'A' is alphabet
'a' is alphabet
'1' is not alphabet
'@' is not alphabet
';' is not alphabet
' ' is not alphabet
'.' is not alphabet
'0' is not alphabet