Program to check whether a character is an alphabet or not in C

Source Code

// 15. Program to check whether a character is an alphabet or not
// Arpan Das - CST 2nd Year (VOCLET)

#include <stdio.h>
//#include <conio.h>
//#include <stdlib.h>

void main () {
	int i, j;
	char ch; // ascii alphabet range 65-90(A-Z), 97-122(a-z)
	//system("cls");
	//clrscr();

	printf("\t\t..:: check whether a character is an alphabet or not ::..\n\n");
	printf("pleae enter any character: ");
	scanf("%c", &ch);
	//ch = getch();
	
	if ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122))
		printf("%c is an alphabet.\n", ch);
	else 
		printf("%c is not an alphabet.\n", ch);	
	
	//getch();
}

Output

		..:: check whether a character is an alphabet or not ::..

pleae enter any character: A
A is an alphabet.

		..:: check whether a character is an alphabet or not ::..

pleae enter any character: 5
5 is not an alphabet.

Leave a Reply

Note: Your email address will not be published. Required fields are marked *