C Program to check string is alphabet or not
In this program, You will learn how to check string is an alphabet or not in c.
Some list of alphabet string: xiith, john, amit, abc
Example: How to check string is an alphabet or not in c.
#include<stdio.h>
#include<string.h>
int main() {
char str[100];
int i = 0, k = 0, p;
printf("Enter string value:");
scanf("%[^\n]%*c", str);
i = strlen(str);
for (int j = 0; j < i; j++) {
p = str[j];
if (p >= 97 && p <= 122)
k++;
else if (p >= 65 && p <= 90)
k++;
else if (p == 32)
k++;
}
if (k == i) {
printf("String is Alphabet:%s", str);
} else {
printf("String is not Alphabet:%s", str);
}
return 0;
}
Output:
Enter string value:Welcome to Xiith
String is Alphabet:Welcome to Xiith