C program to check character is alphabet or not
#include
int main()
{
char c; // character variables
printf("Enter a character: "); // user enter character value
scanf("%c", &c); // stpre value
// check character or not
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
printf("%c is an alphabet.", c);
else
printf("%c is not an alphabet.", c);
return 0;
}
Output
Enter character *
* is not character
How program works ?
- In this program, 'a' is used instead of 97 and 'z' is instead of 122.
- Similarly, "A" is used instead of 65 and "Z" is instead of 90.
Happy coding
0 comments:
Post a Comment