This article contains C++ program to
check whether a character is alphabet or not. A C++ compiler determines characters by its ASCII Values. The alphabetic characters have ASCII values
between 65 to 92 or 97 to 122. Alphabets can be of either lowercase or
uppercase.
C++ program to check whether a
character is alphabet or not
#include<iostream>
using namespace std;
int main()
{
char n;
cout<<"Enter a
number : ";
cin>>n;
if(n>='a'&&
n<='z' || n>='A' && n<='Z')
cout<<endl<<n<<" is an alphabet";
else
cout<<endl<<n<<" is not an alphabet";
return 0;
}
OUTPUT 1:
Enter a number : a
a is an alphabet
OUTPUT 2:
Enter a number : B
B is an alphabet
OUTPUT 3:
Enter a number : *
* is not an alphabet
OUTPUT 4:
Enter a number : 5
5 is not an alphabet
0 comments:
Post a Comment