isalpha()
is a function in C that is used to check if the argument passed to it is in the alphabet. If the argument is not in the alphabet, then the function will return a zero, else it returns a non-zero value.
isalpha()
worksisalpha()
takes in an argument and converts it to ASCII. If the ASCII value is between 65 and 90 or between 97 and 122, it returns a non-zero value. If the ASCII value is out of these two ranges, zero is returned.
The following code takes an array of characters and checks to see if the characters are in the alphabet or not:
#include<stdio.h>#include<stdlib.h>#include <ctype.h>int main(){char str[5] = {'%','&','7','A','t'};int arr[5]={0,0,0,0,0}; //to place the return values of all//characters stored in str array.for (int i=0;i<5;i++){arr[i]= isalpha(str[i]);}for (int i=0;i<5;i++){printf( "\nCharacter ");printf("%c", str[i]);if (arr[i]!=0)printf( " is an Alphabetic");else printf( " is NOT an Alphabetic");}return 0;}
Free Resources